I am displaying a value in directory.php page and then i want to display the result when clicked on the detail hyperlink , specific record to be shown in the directorydetail.php , but it is not showing. :(
i am submitting the code in chunks,

<td width="90"><?php echo $row_Directory; ?></td>
<td width="90" bgcolor="#666666"><a href="directory_detail.php?id=<?php echo $row_Directory; ?>">Details</a></td>


/////////// query for the details of the directory table///////////////
mysql_select_db($database_Connection, $Connection);
$query_Directory = "SELECT Sno,Name, Department, Designation, Off_tel, Res_tel, Mobile_Num, Fax_num, Email_Address FROM directory where Sno=$_GET ";
$Directory = mysql_query($query_Directory, $Connection) or die(mysql_error());
$row_Directory = mysql_fetch_assoc($Directory);

<td><?php echo $row_Directory; ?></td>

6 Years
Discussion Span
Last Post by khushhappy

In your select, you forgot to enter the value for Sno, should be:

$query = "select * from table where Sno = {$_GET['Sno']}";

I prefer $_REQUEST to $_GET, btw - it will work with both get and post variables.

Edited by NettSite: n/a


after placing down the code , i had the problem pasted below

Notice: Undefined index: Sno in C:\wamp\www\directory\directory_detail.php on line 52
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

and line 52 is :
$query_Directory = "select * from directory where Sno ={$_REQUEST}";


Look at your link:

<a href="directory_detail.php?id=<?php echo $row_Directory['Sno']; ?>">

and you will see that you should be using

$query_Directory = "select * from directory where Sno ={$_REQUEST['id']}";
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.