|
Posted by Kimmo Laine on 02/13/07 06:45
"eholz1" <ewholz@gmail.com> wrote in message
news:1171321767.611070.208900@p10g2000cwp.googlegroups.com...
> Hello PHP programmers.
>
> I had a brilliant idea on one of my pages that selects some data from
> my mysql database.
> I first set the page up to display some info and an image, just one
> item, with a row of data, etc.
>
> then I thought it would be nice to do a select, and perhaps an update
> (the title of the image) on the same page.
>
> I am wondering if I am having the wrong idea. I have a form, with two
> submit buttons, one selects an image, and some info. the other will
> update the image title for the given image (id, and p).
> I am seeing that I have a mistake here, since it seems the update
> query will run as well as when the select query is run (select button
> clicked). this overwrites my image titles in the db.
>
> I have the wrong idea, but have not seen how to do this "right". I
> could use another php page for update, but I am guessing this can be
> done from the same page.
>
> Below is my poor code - i am not an expert programmer!!! any help,
> suggestions will be helpful.
Too long code, didn't read it all, but here's a tip for you: Have two submit
buttons, but name them differently. On server-side you test which button was
clicked based on which submit was sent. (Of several submit buttons, only the
one that was clicked is sent in the form)
<input type="submit" name"select" value="select-a-mundo!" />
<input type="submit" name"update" value="update-a-mundo!" />
on server-side this code will tell you which was clicked:
<?php
if(isset($_POST['select'])){
// Now you run the select query
} else if(isset($_POST['update'])){
// Now run the update query
}
?>
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)
Navigation:
[Reply to this message]
|