Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP MySQL Record Issue 2

Status
Not open for further replies.

chris921

Technical User
Mar 9, 2004
82
0
0
GB
Hiya

I'm new to PHP and sorry if I'm asking a stupid question.

Right my problem...
I query a table and return a summary of each record as a row in a html table. Next to the summary I want the user to be able to select a link which loads a new page displaying the complete records details.

My problem is how do I pass which record has been selected to know which record to display in detail?

Thanks in advance
 
You can dynamically create a link tht contains the records ID for instance. When you click the link the id is passed to the detail page, a query is run based on the ID passed and it returns the results for that row.

For example:
In the loop that creates a table for the summary you can include the html necessary to create the link.
Code:
echo "<a href='mydetailpage.php?recordsID='. $row['field'].">Click this link to go to detail page</a>";

This creates a linke that ould look somethng like:
mydetailpage.php?recordsID=2432


Then in your detail page you can pick up the ID passed and issue the query. From the $_GET superglobal.

Code:
$sql="SELECT *FROM mytable WHERE recordID=" . $_GET['recordsID'];

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks for your reply but I can't seem 2 get it to work.
Below is an extract from my code where I've tried to use your suggestion.

Code:
$k=0;
while ($k < $numt) {
$description = mysql_result($resultt,$k,"WorkType");
$MOpened = mysql_result($resultt,$k,"Opened");
$MClosed = mysql_result($resultt,$k,"Closed");
$RDate = mysql_result($resultt,$k,"Next Review");
$output = "<a href='clientmatter.php?MatterRef=".$k['MatterRef'].">View</a>";

print "<TR><TD><font face=\"Arial\">$TNo</font></TD><TD><font face=\"Arial\">$description</font></TD><TD><font face=\"Arial\">$MOpened</font></TD><TD><font face=\"Arial\">$MClosed</font></TD><TD><font face=\"Arial\">$RDate</font></TD><TD><font face=\"Arial\">$output</font></TD></TR>";
$optionsf.="<OPTION VALUE=\"$fid\">".$Tno.'</option>';
 $k++;

I'm not sure where I'm going wrong so any help with be extremely useful

Thanks in advance
 
i'm not understanding your use of variables. you seem to be using the $k variable as a counter or numeric identifier (note that while() command). by contrast you seem also to be using $k as an associative array ($k['matterref']). i don't think that combining these two forms of array will work in the way that you intend.

The link html is also malformed, without a closing single quote.

perhaps you should replace the link with this

Code:
$output = "<a href='clientmatter.php?MatterRef=".mysql_result($resultt, $k, "MatterRef")."'>View</a>";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top