473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1716
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
12
by: Mary Catherine | last post by:
I have 2 scipts that I am trying to get to run on the same page. One is a time/date script, the other is a countdown script (i.e. countdown days, hours, mins until a given date). They both work...
84
by: Bibby | last post by:
Hi, I'm interested in getting started in the programming world. I've dabbled in C, C++ and VB6. Which would be the best language to focus my attention to regarding the following considerations: ...
4
by: ano | last post by:
I have a console application and a lot of Console.WriteLine(). Now I want to convert it to Windows Form Application. Is it possible to getting all of the console messages to Form.Textbox without...
6
by: sgottenyc | last post by:
Hello, If you could assist me with the following situation, I would be very grateful. I have a table of data retrieved from database displayed on screen. To each row of data, I have added...
1
by: ced69 | last post by:
having trouble getting marquee to work get object required errors tring t <title>This Month at the Chamberlain Civic Center</title> <link href="styles.css" rel="stylesheet"...
4
by: Bernie | last post by:
Hello all, I am new to the group and new to javascripting, so I am hoping to find some good help here. Here is a snippet of my code: HTML: Name: <input type="text" name="ageName0"...
18
by: Quizzed | last post by:
Hi, New user here and using a ms access 97 database. I have a form containing a list box which presents the contents of a table. On double clicking a record, i need the record to be presented...
8
by: Innocent2104 | last post by:
Hi there, The script below displays the attached output but as shown, it skips certain days and i need to include these to calculate my avg balance for a certain month, i.e.Nov. How do i update the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.