PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi
I don't speak well the English
The problem is:
I have a select menu as this
how can I cancel from my DB a selected item?
I for example select "New York"
and with a key delete, would like that he was cancelled by my DB.
Many thanks
I have no idea what you're asking specifically.. I get the really general idea, sorta.. Maybe you should post it in your spoken language (and tell us what language that is.)
Je ne comprende pas comment son code(c'est francais pour "code"?) productions la HTML.
Je crois il veut a effacer un rapport (record) quand il choisit "New York".
English:
Yes, I know my french is weak. It happens when you don't speak it ever.
OK I'm hoping that "prodotto" is the primary key in your database? Something like a "product ID". If it's not, you will need something else unique in your <option> value="" atrribute so that you can find a record in your database to delete
preg_match('/^prodotto:(.*?),/', $_POST['pippo'], $matches); //Use regex to extract the product ID from the POST data
$prodotto = $matches[1]; //This is the product ID ??
mysql_query("DELETE FROM ordini WHERE prodotto = $prodotto LIMIT 1") or die(mysql_error()); //Run the query to delete the record
//show a confirmation message
EDIT | Looking at your SELECT query I'm confused why you use the session ID as the ID in the database which suggests to me to be a primary key (ID) ? Or perhaps you don't want to delete an entire row, you only want to delete one value?
Thanks d11wtq
the select of the city was as example.
I want to cancel a whole line, not only a value,a whole line is composed from more values
I want:
1)to select a line
2)to press a button that cancels the whole line
excuse but yesterday I have gone to sleep
Many thanks.
okay.. things you need: a delete page (could be the same script as the form is on)
the use of the onchange event attached to the selectbox.
That's about it...
Thanks feyd
"I have many problems with the English, Sorry"
the select of the city was as example.
I want to cancel a whole line, not only a value,a whole line is composed from more values
I want:
1)to select a line
2)to press a button that cancels the whole line
3)I don't want redirect in another page
I want use
<form action=\"".$_SERVER['PHP_SELF']."\"
is it possible?
right, it was the easiest example at hand for me to work with, since your code posted is marginally scary
NOVI wrote:I want to cancel a whole line, not only a value,a whole line is composed from more values
That's the idea behind what I posted.
NOVI wrote:I want:
1)to select a line
2)to press a button that cancels the whole line
okay, that basically removes the onchange event and leaves it as normal.
NOVI wrote:3)I don't want redirect in another page
I want use
<form action="".$_SERVER['PHP_SELF'].""
is it possible?
absolutely.. you simple have to code the script such that when a submission is detected it does the deletion (although I would recommend adding a confirm screen between the two)