You are here: Re: have to "actions" or run two types of queries (select,and update) on the same form? « PHP Programming Language « IT news, forums, messages
Re: have to "actions" or run two types of queries (select,and update) on the same form?

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]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° 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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация