469,643 Members | 2,064 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Getting ID from a presented table

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
Mar 18 '07 #1
12 1550
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.
js*******@attglobal.net
==================
Mar 18 '07 #2

"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:xt******************************@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.
js*******@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?
Mar 18 '07 #3

"Lennart Anderson" <le**************@tele2.seskrev i meddelandet
news:n%***************@nntpserver.swip.net...
>
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:xt******************************@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.
js*******@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?
Furthermore, if I click a link on a displayed record I can only get
information from the link of the last displayed record. How to get
information of the ID from any of the earlier displayed records?
Mar 18 '07 #4
Lennart Anderson wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:xt******************************@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.
js*******@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.
js*******@attglobal.net
==================
Mar 18 '07 #5
Lennart Anderson wrote:
"Lennart Anderson" <le**************@tele2.seskrev i meddelandet
news:n%***************@nntpserver.swip.net...
>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:xt******************************@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.
js*******@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?
Furthermore, if I click a link on a displayed record I can only get
information from the link of the last displayed record. How to get
information of the ID from any of the earlier displayed records?

If you want to get information from previously displayed records you're
going to have to save them and pass them along somehow - i.e in a
session or hidden fields in your form.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 18 '07 #6

"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:yb******************************@comcast.com. ..
Lennart Anderson wrote:
>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:xt******************************@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.
js*******@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.
js*******@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?
Mar 19 '07 #7
Lennart Anderson wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:yb******************************@comcast.com. ..
>Lennart Anderson wrote:
>>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:xt******************************@comcast.co m...
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.
js*******@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.
js*******@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.
js*******@attglobal.net
==================
Mar 19 '07 #8

"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:0o******************************@comcast.com. ..
Lennart Anderson wrote:
>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:yb******************************@comcast.com ...
>>Lennart Anderson wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:xt******************************@comcast.c om...
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.
js*******@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.
js*******@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.
js*******@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!';
}
Mar 19 '07 #9
Lennart Anderson wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:0o******************************@comcast.com. ..
>Lennart Anderson wrote:
>>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:yb******************************@comcast.co m...
Lennart Anderson wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:xt******************************@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.
>js*******@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.
js*******@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.
js*******@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!';
}

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.
js*******@attglobal.net
==================
Mar 19 '07 #10

"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:wv******************************@comcast.com. ..
Lennart Anderson wrote:
>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:0o******************************@comcast.com ...
>>Lennart Anderson wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:yb******************************@comcast.c om...
Lennart Anderson wrote:
>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
>news:xt******************************@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.
>>js*******@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.
js*******@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.
js*******@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!';
}


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.
Thanks. This seems most promising but don't I need to have some kind of
form method to pass the $_GET variable. Just now the table is presented
without any kind of form tags.
js*******@attglobal.net
==================

Mar 19 '07 #11
Lennart Anderson wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:wv******************************@comcast.com. ..
>Lennart Anderson wrote:
>>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:0o******************************@comcast.co m...
Lennart Anderson wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:yb******************************@comcast. com...
>Lennart Anderson wrote:
>>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
>>news:xt******************************@comcas t.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.
>>>js*******@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.
>js*******@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.
js*******@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!';
}

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.

Thanks. This seems most promising but don't I need to have some kind of
form method to pass the $_GET variable. Just now the table is presented
without any kind of form tags.
>js*******@attglobal.net
==================

You need a form to pass values via POST. But GET values can be passed
in the href. Check alt.html for more info on this.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 19 '07 #12

"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:ye******************************@comcast.com. ..
Lennart Anderson wrote:
>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:wv******************************@comcast.com ...
>>Lennart Anderson wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
news:0o******************************@comcast.c om...
Lennart Anderson wrote:
>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
>news:yb******************************@comcast .com...
>>Lennart Anderson wrote:
>>>"Jerry Stuckle" <js*******@attglobal.netskrev i meddelandet
>>>news:xt******************************@comca st.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.
>>>>js*******@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.
>>js*******@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.
js*******@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!';
}
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.

Thanks. This seems most promising but don't I need to have some kind of
form method to pass the $_GET variable. Just now the table is presented
without any kind of form tags.
>>js*******@attglobal.net
==================


You need a form to pass values via POST. But GET values can be passed in
the href. Check alt.html for more info on this.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
No way I can get this to work. The only way I can get the link to reat is by
using:
'<a href= "advertinfo.php?id=$row->ID" >' . ($row->adheader).
But then the id is not parsed in the right way o by looking at th HTML-code
in the browser View source the link is still: <a href=
"advertinfo.php?id=$row->ID" >. When I click and use the $_GET on the linked
page I just get: $row->ID as the answer.
HOw do I get the link to interprete the ID-number and to use that as the
link-parameter.
I admit that I am not too experienced in php but have the intention to learn
but this thing is going to drive me more crazy than usual.
Mar 20 '07 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

303 posts views Thread by mike420 | last post: by
12 posts views Thread by Mary Catherine | last post: by
84 posts views Thread by Bibby | last post: by
6 posts views Thread by sgottenyc | last post: by
4 posts views Thread by Bernie | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.