Line break where there shouldn't be one

First off, thanks for all your help on my last question. I’ve got my site up and functional, but have run into another problem. I’m running a while loop to show all the users of a certain userlevel on a page, sort of like a member list. However, I’m having 2 problems:

  1. First member the while loop comes across is not being shown.
  2. After the first loop, it puts the next table on a new line. I want to have a line of 4 users and then go to the next line.

How can I do that?

[php]

<? /** Girls.php */ include("session.php"); ?> <?php // Collects data from "users" table $data = mysql_query("SELECT * FROM users WHERE userlevel='6' ORDER BY status") or die(mysql_error()); // puts the "users" info into the $info array $info = mysql_fetch_array( $data ); ?>

//echos girls username, picture, and status

<?php echo "
"; while($info = mysql_fetch_array( $data )) { echo ""; echo ""; echo "
".$info['username'] . "
"; echo "
"; echo "
"; echo " "; } echo "
"; ?>

[/php]

Thanks in advance!

Hello,

You need to remove this code what you have before your while loop (that’s the reason why first record is not displayed in the loop):
[php] // puts the “users” info into the $info array
$info = mysql_fetch_array( $data );[/php]

As for displaying 4 users per line, check this post to see how to display MySQL query results in multiple columns. You will only need to adjust parameter - number of columns, and within the loop replace the code that displays one table cell:
[php]echo ‘

’.htmlspecialchars($f[“FieldName1”]).’’;[/php]

to your. I assume, modified code will look like this:
[php]
echo ‘

’;

// here goes 1 cell content
echo “

”;
echo “”;
echo “<td align=‘center’ background=’” .$f[‘image’] ."’>";
echo “
<img src=“images/”.$f[‘status’] . “.jpg”>”;
echo “
”.$f[‘username’] . “
”;

echo ‘

’;
[/php]

That worked perfectly! Thanks so much!

Sponsor our Newsletter | Privacy Policy | Terms of Service