Page 1 of 1

Member help

Posted: Tue Aug 17, 2004 3:48 am
by ek5932
I want to seperate all my users into a sector sort of thing with 20 users to one sector. In the sector when there are no users instead of not showing anything and setting a max limit to 20 i want it to display as empty and every time a user joins up from the bottom upwards the empty changes to a user. The current code I have is

Code: Select all

<?
include 'db.php';
  $result = @mysql_query("SELECT kingdom_name, x, y, net FROM users WHERE galaxy='$g' AND sector='$s' ORDER BY userid ASC");
  if (!$result) &#123;
    echo("<p>Error performing query: " . mysql_error() . "</p>");
    exit();
  &#125;
  while ( $row = mysql_fetch_array($result) ) &#123;
  echo("<tr bgcolor=222222><td>" . $row&#1111;"kingdom_name"] . " (X:" . $row&#1111;"x"] . ",Y:" . $row&#1111;"y"] . ")</td>");
    echo("<td>" . $row&#1111;"net"] . "</td></tr>");
	&#125;
?>
But that just loops all the kingdoms and displays nothing when no one has signed up. Any help would be greatly apreciated.

Posted: Tue Aug 17, 2004 10:12 am
by feyd
using [php_man]mysql_num_rows[/php_man](), you can check how many were found, if any. This will allow you to write out empty and whatnot..

Posted: Tue Aug 17, 2004 12:00 pm
by ek5932
I tried looking at that but it dosnt give me much help. I will keep on looking around.

Posted: Tue Aug 17, 2004 12:07 pm
by John Cartwright
How does it not help you?

Posted: Tue Aug 17, 2004 4:49 pm
by ek5932
I get the result but im not sure how to loop the results empty or the users details

Posted: Tue Aug 17, 2004 4:55 pm
by feyd
if num_rows returns zero, you print an empty results signage.. otherwise, do your loop..

Posted: Tue Aug 17, 2004 5:25 pm
by ek5932
i must of explained my self wrong. if there is 1 user there are 19 rows field with empty and 1 with the users details, not just say its empty

Posted: Tue Aug 17, 2004 5:27 pm
by feyd
okay.. then take the difference of your limit and the number found.. print that many empty slots... :?

Posted: Tue Aug 17, 2004 6:08 pm
by ek5932
thanks :D