0

Okay, I'm a little confused - this code works perfectly fine in mysql; however, in php it keeps repeating the first person for about 15 rows. Can someone point me to what I'm missing here.

$queryUsers = "SELECT user_id, zipcode, gender, housing_status, active, username FROM users WHERE user_id != '" . $_SESSION['user_id'] . "'
					AND active = 1";
	$dataUsers = mysqli_query($dbc, $queryUsers);
	$rowUsers = mysqli_fetch_array($dataUsers);
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	  while ($row = mysqli_fetch_array($dataUsers)) {

			echo '
				<tr><td class="subtitle" height="30px" colspan="3" align="left" valign="middle">' . $rowUsers['username'] . '</td></tr>
				<tr><td width="21%" rowspan="8" align="center" valign="middle"><img alt="profile picture" name="profilepic" width="100" height="100" id="profile picture" /></td></tr>
				<tr class="oddrow"><td width="21%" align="left" valign="middle">Age:</td><td width="58%">' . $rowUsers['user_id'] . '</td></tr>
				<tr class="evenrow"><td align="left" valign="middle">Gender:</td><td>' . $rowUsers['gender'] . '</td></tr>
				<tr><td align="left" valign="middle">Location:</td><td>&nbsp;</td></tr>
				<tr class="evenrow"><td align="left" valign="middle">Looking for:</td><td>' . $rowUsers['housing_status'] . '</td></tr>
				<tr><td align="left" valign="middle">Has children:</td><td>&nbsp;</td></tr>
				<tr class="evenrow"><td align="left" valign="middle">Type of pets:</td><td>&nbsp;</td></tr>
				<tr class="oddrow"><td align="left" valign="middle">Inside Smoker:</td><td>&nbsp;</td></tr>
				<tr class="subtitle"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
		
	}
	  echo '</table>';

also if i change mysqli_fetch_array to mysqli_num_rows, I get a million empty rows.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by flashyflashy
0

$_SESSION['user_id'] , I guess this is causing problem.
Try

$session_user=$_SESSION['user_id'];
$queryUsers = "SELECT user_id, zipcode, gender, housing_status, active, username FROM users WHERE user_id != '" . $session_user. "' AND active = 1";

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.