Jump to content

[SOLVED] Query..


runei

Recommended Posts

Hello. Can someone explain the difference of the following 2 querys? The first one works, sort of. I get all the id's in the table but only if i use an alias.

The second one i dont get. I have defined the id as a variable of id. I only get a blank page. I know the code is wrong but could someone be helpful and explain the "correct" way to do it? Thx a bunch in advance. :)

 

runei

 

 

<?php
include "../globals.php";





                         
		$query = "SELECT id AS LOK FROM forum_replies";
		$result = mysql_query($query);
		$number = mysql_num_rows($result);

		if ($number == 0) {
			echo "no output";
			}else{ 


echo '<table border ="1" align="center" cellspacing="3" cellpadding="3" width="75%">
#<tr><td align="left"><b>blahblah</b></td>';


while ($row = mysql_fetch_array($result)) {
	echo '<tr><td align="left">' . $row['LOK'] .  '</td></tr>
	';
}

echo '</table>'; 
}		
?>

 

 

<?php
include "../globals.php";

$id = ($_GET['id']);
if($id){



                         
		$query = "SELECT * FROM forum_replies WHERE id='".$id['id']."'"; 
		$result = mysql_query($query);
		$number = mysql_num_rows($result);

		if ($number == 0) {
			echo "no output";
			}else{ 


echo '<table border ="1" align="center" cellspacing="3" cellpadding="3" width="75%">
<tr><td align="left"><b>blahblah</b></td>';


while ($row = mysql_fetch_array($result)) {
	echo '<tr><td align="left">' . $row['id'] .  '</td></tr>
	';
}

echo '</table>'; 
}		
}
?>

Link to comment
https://forums.phpfreaks.com/topic/127745-solved-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.