You are here: Re: Adding hyperlinks to a table? « PHP SQL « IT news, forums, messages
Re: Adding hyperlinks to a table?

Posted by J.O. Aho on 10/14/56 11:32

Sam wrote:
>>> <?php echo "<a href='http://$url_to_page?ID=$id&Zip=$postcode&'><img
>>> src='images/uglypicture.png' border='0'></a>"; ?>
>
>>> You need to set the $url_to_page to which page to load and $id needs to be set
>>> to the user id while $postcode needs to be set to the post code.
>
> Thanks so much for the quick reply!!
>
> This kind of makes sense - but will this work for multiple rows - each
> with their own button.
>
> For example - this is what my HTML table may look like:
>
> England HP19 3TY 10/08/2006
> <<button>>
> America 11798 01/01/2006
> <<button>>
>
> The buttons are not actually part of the table. Now - if I click either
> of the buttons, I want the postode and date for the adjacent row to be
> sent to the page as in your example - but how do I link each button to
> each row - if you see what I mean? The rows are a simple HTML table and
> the button would be a separate gif/png/whatever that sits adjacent to
> each row....

You have most likely a code something like

while($row=mysql_fetch_array($result) {
echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[3]."</td></tr>";
}

change it to
while($row=mysql_fetch_array($result) {
echo
"<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>"."<a
href='http://$url_to_page?ID=".$row[3]."&Zip=".$row[1]."&'><img
src='images/uglypicture.png' border='0'></a></td></tr>";
}

This gives you a design of

+--------+----------+------+---------------------+
| Contry | Postcode | Date | Button (id,postcode)|
+--------+----------+------+---------------------+
| Contry | Postcode | Date | Button (id,postcode)|
+--------+----------+------+---------------------+

My example requires that you fetch the data from the sql table in a special order

SELECT contry,postcode,date,id FROM yourtable

Of course you can fetch more data if you want, as I don't know how your tables
look, you may need some "left join" if you have split things up in many tables
instead of using one huge one.

I guess your system is some kind of ordering system, then you should have the
id as a primary key and then you should only need to send the id and not both
id and postcode to fetch the further information about the order.


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация