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>


directorydetail.php

/////////// 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>&nbsp;</td>
<td><?php echo $row_Directory; ?></td>
<td>&nbsp;</td>

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.

@Nettsite:
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']}";

@nettsite: ya , this worked out .solved. Thanks for the post

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.