I've been dabbling with PHP and MYSQL over the last month or so. I like
it! However, I'm stumped and hope you guys 'n' gals can give me some
advice.
I can visualise what I want to achive but don't know how complex, (or
easy :o), this will be to do in practice.
* I have a simple MySQL database containing User ID, Country, Postcode
and Date.
* I extract this information and display it in a table, depending on
which user is logged in. (I use sessions). Typically, there will be 4
or 5 rows of data displayed for each user.
I want to have an image, (a button), displayed alongside each row which
the user can click on to select that row.
When clicked, this button should take the User ID and Postcode for it's
row and pass this to another PHP function.
Easy?!?!!
Hard!??!!
Impossible?!!?
Hit me with it, guys :o)
Sam Day.
Re: Adding hyperlinks to a table?
am 18.11.2005 16:51:33 von Shion
Sam wrote:
> Hello!
>
> I've been dabbling with PHP and MYSQL over the last month or so. I like
> it! However, I'm stumped and hope you guys 'n' gals can give me some
> advice.
>
> I can visualise what I want to achive but don't know how complex, (or
> easy :o), this will be to do in practice.
>
> * I have a simple MySQL database containing User ID, Country, Postcode
> and Date.
>
> * I extract this information and display it in a table, depending on
> which user is logged in. (I use sessions). Typically, there will be 4
> or 5 rows of data displayed for each user.
>
> I want to have an image, (a button), displayed alongside each row which
> the user can click on to select that row.
>
> When clicked, this button should take the User ID and Postcode for it's
> row and pass this to another PHP function.
src='images/ugglypicture.png' border='0'>"; ?>
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.
Of course you could store the values needed in the session and just have a
simple link.
>> 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
<
Re: Adding hyperlinks to a table?
am 19.11.2005 08:35:56 von Shion
Sam wrote:
>>>
>>> src='images/uglypicture.png' border='0'>"; ?>
>
>>> 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
> <>
> America 11798 01/01/2006
> <>
>
> 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 "
".$row[0]."
".$row[1]."
".$row[3]."
";
}
change it to
while($row=mysql_fetch_array($result) {
echo
"
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
Re: Adding hyperlinks to a table?
am 19.11.2005 19:16:24 von salmondays2000
>> My example requires that you fetch the data from the sql table in a special order
Ahhhhhh.... I see!
That's really cool :o)
Thanks *very* much!
Sam Day.
Re: Adding hyperlinks to a table?
am 11.01.2006 04:43:07 von Jim Michaels
I will take it a step further. it sounded like you wanted to change the
image too. easy enough. just make flag (or whatever) images for the
appropriate countries using the country name as a base filename, and do this
slight modification (and by the way, you can use column names instead of
numbered array indices, and you can do away with the concatenation):
while($row=mysql_fetch_array($result) {
echo
"
$row[Contry]
$row[Postcode]
$row[Button]
";
}
change it to
while($row=mysql_fetch_array($result) {
echo
"
"J.O. Aho" wrote in message
news:3u82utFvkcriU1@individual.net...
> Sam wrote:
>>>>
>>>> src='images/uglypicture.png' border='0'>"; ?>
>>
>>>> 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
>> <>
>> America 11798 01/01/2006
>> <>
>>
>> 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
> "
".$row[0]."
".$row[1]."
".$row[3]."
";
> }
>
> change it to
> while($row=mysql_fetch_array($result) {
> echo
> "
";
> }
>
> 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