Re: Getting ID from a presented table
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Mon, 19 Mar 2007 14:01:26 -0500
Lennart Anderson wrote:
"Jerry Stuckle" <jstucklex@xxxxxxxxxxxxx> skrev i meddelandet news:0oGdneT-v7svMmPYnZ2dnUVZ_s3inZ2d@xxxxxxxxxxxxxxLennart Anderson wrote:"Jerry Stuckle" <jstucklex@xxxxxxxxxxxxx> skrev i meddelandet news:ybqdnXJcAfixAmDYnZ2dnUVZ_vPinZ2d@xxxxxxxxxxxxxxOK, posting the code you're using would help a lot.Lennart Anderson wrote:No, I do not know how to do that in HTML."Jerry Stuckle" <jstucklex@xxxxxxxxxxxxx> skrev i meddelandet news:xtCdnUF-VpfLF2DYnZ2dnUVZ_rbinZ2d@xxxxxxxxxxxxxxDo you know how to do it in html? Same idea - just generated with a PHP echo statement instead.Lennart Anderson wrote:I think I get the idea but I don't know how to doo that. Can you give me an aidea of how such a link with, I guess, embedded ID would look like?I'm having a MySQl table wih a lot of information. I want to present some main fields in a table on one page. Each record do, of course, have a unique ID. The presnted table will have one field as a linked field. I want to be able to click this link, retreive the ID information for that record and then present detailed data for that record on the next page.Put the id in the link itself.
How do I retreive the ID?
Any hints are very much appreciated.
Thanks
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
But, once again, the problem is that I have a number of records presented in a table. All records do have unique ID. When preseneted by the hTML page they are parsed into "hard-coded" HTML and although I can have a field to act as a link I can't get the ID for the special record I am selecting. Only the ID for the last presented record will come through since that ID is still present in the array. Any hint of how to get the ID from any selected record?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
Here is the essential part of the code with the presneted table where one of the records field will be a link. I want to retreive the ID for any selefted record from, say, 25 presented.
mysql_select_db('db2') or die ('Unable to select database!');
// create and execute query
$query = "SELECT ID, DATE_FORMAT(addate, '%m-%d') AS adday, DATE_FORMAT(addate, '%H:%i')as adtime, addate, adnamn, adcat, adheader,adtext,adprice,adcats.catname FROM ads, adcats where ads.adcat = adcats.catid order by ID DESC";
$result = mysql_query($query)
or die ('Error in query: $query. ' . mysql_error());
// check if records were returned
if (mysql_num_rows($result) > 0)
{
// iterate over record set
// print each field
echo '<h2>Test on data retrieval from the data base</h2></br>';
echo '<table border=0 cellpadding=2 width = 100% bgcolor="#FFFF99" bordercolor="#FFFFFF">';
echo '<tr>
<td>Ad-No.</td>
<td>Day</td>
<td>Time</td>
<td>Ad-header</td>
<td>Price CI$</td>
<td>Category</td>
</tr>';
while($row = mysql_fetch_object($result))
{
echo '<tr>';
echo '<td width=5% bgcolor="#FFFFFF" align = "right">' . ($row->ID) . '</td>';
echo '<td width=4% bgcolor="#FFFFFF">' . ($row->adday) . '</td>';
echo '<td width=5% bgcolor="#FFFFFF">' . ($row->adtime) . '</td>';
echo '<td width=40% bgcolor="#FFFFFF">' . '<a href= "advertinfo.php" >' . ($row->adheader) . '</td>';
echo '<td width = 6% bgcolor="#FFFFFF" align = "right">' . ($row->adprice) . '</td>';
echo '<td width = 18% bgcolor="#FFFFFF">' . ($row->catname) . '</td>';
echo '</tr>';
}
echo '</table>';
}
else
{
// print error message
echo 'No rows found!';
}
OK, if you're going to make it a link, you have to pass the id as a parameter in the link, i.e.
echo '<td width=40% bgcolor="#FFFFFF">' . '<a href= "advertinfo.php?id=' .. $row['id'] . " >' . ($row->adheader) . '</td>';
This will pass the link as "advertinfo.php?id=3", for example.
Then in advertinfo.php you use access it with $_GET['id'].
Be sure to use isset($_GET['id']) in case someone comes to this page without an id being passed.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: Getting ID from a presented table
- From: Lennart Anderson
- Re: Getting ID from a presented table
- References:
- Getting ID from a presented table
- From: Lennart Anderson
- Re: Getting ID from a presented table
- From: Jerry Stuckle
- Re: Getting ID from a presented table
- From: Lennart Anderson
- Re: Getting ID from a presented table
- From: Jerry Stuckle
- Re: Getting ID from a presented table
- From: Lennart Anderson
- Re: Getting ID from a presented table
- From: Jerry Stuckle
- Re: Getting ID from a presented table
- From: Lennart Anderson
- Getting ID from a presented table
- Prev by Date: how do xml parsers detect bad characters?
- Next by Date: Re: Progress DB
- Previous by thread: Re: Getting ID from a presented table
- Next by thread: Re: Getting ID from a presented table
- Index(es):
Relevant Pages
|