Hanging on Database query multiple columns

$q = "SELECT FIELD1 as dr, URL as name FROM website0 ORDER BY URL ASC";		
$r = @mysqli_query ($dbc, $q); 

$num = mysqli_num_rows($r);

if ($num > 0) { 

	echo "<p>There are currently $num registered users.</p>\

	echo '<table align="center" cellspacing="3" cellpadding="3" width="75&#37;">
	<tr><td align="left"><b>Name</b></td><td align="left"><b>Date Added</b></td></tr>
	while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
		echo '<tr><td align="left">' . $row['name'] . '</td><td align="left">' . $row['dr'] . '</td></tr>

	echo '</table>';
	mysqli_free_result ($r);

} else {

	echo '<p class="error">There are currently no registered users.</p>';



      FIELD1 as dr
    , URL as name
    name ASC

With your original query MySQL is probably trying to sort the results set by a field called “URL” but it wouldn’t find it as you have given the field “URL” an alias called “name”

when i go to access the page through the browser, i get “Waiting for local host…” Right now i only have 1 entry in the table.

just want to output the database table into the html so i can display it as table in the page.

The code works for one column and the html works too, i get 1 column filled and the other blank

but when i add the other column ,URL is the column name and name is the html column i want to put it in

The system hangs when i do this

$q = “SELECT FIELD1 as dr, URL as name FROM website0 ORDER BY URL ASC”;

but works for

$q = “SELECT FIELD1 as dr FROM website0 ORDER BY URL ASC”;

Please add more info what you want to do…

I can’t think of any logical reason why retrieving an extra column would make any difference. How big is the table?

By hang do you mean the browser or the server being overwhelmed?

cool thanks man, that fixes it :):cool:

You probably have an error in your sql. Get rid of the @ before mysqli_query and add:
to the top of your file.

How are you connecting to your db?
I personally use to connect:

$mysqli = new mysqli($host,$user,$pass,$db_name);               
   die('Connection error: ('.$mysqli->connect_errno.'): '.$mysqli->connect_error);

You can use:

//replace with your info
$link = mysqli_connect('localhost', 'fake_user', 'my_password', 'my_db');

if (!$link) {
    die('Connect Error: ' . mysqli_connect_error());