<?php

mysql_connect("localhost", "Master", "pword");
mysql_select_db("db");

	$official2 = mysql_query("SELECT * FROM Contribute WHERE stack LIKE '%comic%' ORDER BY points DESC")or die (mysql_error());
	while($row = mysql_fetch_array($official2)) {
	$officaluser = $row['username'];
	
	$officalpoints = $row['points'];
	
	
	
	echo "<table><tr><td align='center'><font face='Arial' size='3px' color='#D99C29'><strong><a href='ustack.php?search=$officialuser' style='text-decoration: none'>$officialuser</a></strong></font></td><td align='center'><font face='Arial' size='3px' color='#FFFFFF'><strong>$officialpoints</strong></font></td></tr></table>";

}
?>

the page is coming up blank??!?

Recommended Answers

All 3 Replies

Well, if there are no results, nothing will be displayed.

try as given below with @ sign

@mysql_connect("localhost", "Master", "pword");
@mysql_select_db("db"); 	
$official2 = @mysql_query("SELECT * FROM Contribute WHERE stack LIKE '%comic%' ORDER BY points DESC")OR die (mysql_error());
<?php

mysql_connect("localhost", "Master", "pword");
mysql_select_db("db");

	$official2 = mysql_query("SELECT * FROM Contribute WHERE stack LIKE '%comic%' ORDER BY points DESC")or die (mysql_error());
	while($row = mysql_fetch_array($official2)) {
	$officaluser = $row['username'];
	
	$officalpoints = $row['points'];
	
	
	
	echo "<table><tr><td align='center'><font face='Arial' size='3px' color='#D99C29'><strong><a href='ustack.php?search=$officialuser' style='text-decoration: none'>$officialuser</a></strong></font></td><td align='center'><font face='Arial' size='3px' color='#FFFFFF'><strong>$officialpoints</strong></font></td></tr></table>";

}
?>

the page is coming up blank??!?

After a second look at your code, there are a few thing to change. Fist of all, you have the complete table inside the while loop. That means every time the loop executes, a new table is created. So before the while loop you need

echo "<table>";

and after

echo "</table>";

Inside the wile the echo might work if written like this:

echo "<tr><td align='centter'>
    <font face='Arial' size='3px' color='#D99C29'>
    <strong><a href='ustack.php?search=".$officaluser."' style='text-decoration:none'>".$officaluser."</a></strong></font>
</td>
<td align='center'>
    <font face='Arial' size='3px' color='#FFFFFF'>
    <strong>".$officalpoints."</strong></font>
</td>
</tr>

If you don't notice the change, I did place ". and ." around the variables.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.