1) If there are people online (if $online_sql holds a value), I want to limit the creation of the table cells <td>'s to 3, and then if there are more than 3 people online, I want to create a new table row <tr>. And continue this process until all database entries are gathered. If that makes sense? So if there are 9 people online there would be 3 table rows each with 3 table cells in them. Can that be done? Then possibly in the future I could create pages after the number of results hit a certain value (but not yet ).
2)The } else { statement doesnt seem to be working. If no-one is online I want the message to be produced, but at the moment nothing is being displayed? Can I use an if-else statement within the while loop??
I've found some nifty code from webmonkey. Its allowing me to limit the number of photos to 3 pictures per row. I have 4 entries in the database and they are being displayed correctly, but my problem is that the while loop is throwing out the first entry of the database so I am getting 4 duplicate pictures, instead of the 2nd, 3rd, and 4th picture. Here is the code:
PHP Code:
<?
//online?
$online_sql=mysql_query("MY QUERY HERE");
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="border"><tr><td height="20" align="center" bgcolor="#D83C85"><strong>Online / Available NOW!</strong></td></tr></table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
<?
$num_rows = 3;
$photos_per_row = 3;
$photos_per_page = $num_rows * $photos_per_row;
//check to see if the start variable exists in the URL.
//If not, then the user is on the first page - set start to 0
if(!isset($start)){
$start = 0;
}
//init i to where it needs to start in the photos array
$i = $start;
$prev_start = $start - $photos_per_page;
$next_start = $start + $photos_per_page;
$total_photos = mysql_num_rows($online_sql);
Actually, thinking about it I dont need that now do i!!!!
Thanks!
There is another problem I have though. These images are created on the index.php page, where this code is also located:
PHP Code:
if (!isset($_GET["id"])) $_GET["id"]='';
if ($_GET["id"]!=''){
include "profile.php";
} else {
$engine->load();
}
What this does is load the profile for the person depending which image is clicked upon. But the profile is being loaded directly below the images. What I want to do is clear the images from the page and load the profile "cleanly" on its own. Can that be done?
On the index.php file I have all my code which gets the images and links. Then directly below that I have the code:
PHP Code:
if (!isset($_GET["id"])) $_GET["id"]='';
if ($_GET["id"]!=''){
require "profile.php";
} else {
$engine->load();
}
Once an image is clicked it brings up the profile for that certain image/person. This is done by $engine->load(); in the above code, which calls a module and essentially includes a PHP file (which holds the profile for the person). The problem is that the profile is being loaded directly into the index.php file underneath all the images. What I need to do is try to clear the images first, and then load the profile, all within the index.php page, or on a separate page.
I tried to add some kind of page counter, but realised that wouldn't work. Could I not add the above code to the link that is processed using 'onclick' and call a separate file called profile.php? My problem is getting the data into a link format.
Or does anyone have any better ideas? I'm sure there must be something else I can do, for example, is there no function to load a php file in the else statement, or redirect to another file?