|
Posted by Lennart Anderson on 03/19/07 16:17
"Jerry Stuckle" <jstucklex@attglobal.net> skrev i meddelandet
news:0oGdneT-v7svMmPYnZ2dnUVZ_s3inZ2d@comcast.com...
> Lennart Anderson wrote:
>> "Jerry Stuckle" <jstucklex@attglobal.net> skrev i meddelandet
>> news:ybqdnXJcAfixAmDYnZ2dnUVZ_vPinZ2d@comcast.com...
>>> Lennart Anderson wrote:
>>>> "Jerry Stuckle" <jstucklex@attglobal.net> skrev i meddelandet
>>>> news:xtCdnUF-VpfLF2DYnZ2dnUVZ_rbinZ2d@comcast.com...
>>>>> Lennart Anderson wrote:
>>>>>> 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.
>>>>>> How do I retreive the ID?
>>>>>> Any hints are very much appreciated.
>>>>>> Thanks
>>>>> Put the id in the link itself.
>>>>>
>>>>> --
>>>>> ==================
>>>>> Remove the "x" from my email address
>>>>> Jerry Stuckle
>>>>> JDS Computer Training Corp.
>>>>> jstucklex@attglobal.net
>>>>> ==================
>>>> 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?
>>> Do you know how to do it in html? Same idea - just generated with a PHP
>>> echo statement instead.
>>>
>>> --
>>> ==================
>>> Remove the "x" from my email address
>>> Jerry Stuckle
>>> JDS Computer Training Corp.
>>> jstucklex@attglobal.net
>>> ==================
>>
>> No, I do not know how to do that in HTML.
>> 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?
>
> OK, posting the code you're using would help a lot.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================
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!';
}
Navigation:
[Reply to this message]
|