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!
$data = mysql_query("SELECT * FROM Invites WHERE num = " . $_POST['moo'] . "") or die(mysql_error());
It allows the script to work and update the db but then it errors out. I tried everything to change the query ever so slightly to make it happy.
Pickle said it is supposed to display the options they selected, I would be fine with that or if after the submitted if it just took them to another thank you page. Anything so the error stops.
Thanks for the reply. Yes it appears you also understood what I am looking for. After a couple minor changes I got the first two parts of the script working. Unfortunately I can't quite figure out what I need to do with that third part. I messed around with it but nothing I tried came out right.
Pickle, on your script since that one item seems t be causing the problem, would it be possible to make it send the user to another page instead of trying to display the updated info?
This is so frustrating. While I do enjoy this and want to learn a lot more I know I am in over my head on this project. I had a friend helping me on this and he bailed at the last minute. Now I have my wedding coming up and I have to spend my time struggling with this (The invites are already printed and mention RSVP'ing online). I really do appreciate all the help you guys are giving me.
Last edited by RafaelT on Tue Aug 11, 2009 12:07 am, edited 1 time in total.
Yes, I am just not quite sure how to get that query working properly, I can't make sense of all the stuff there 100%.
I know the query needs to be along the lines of UPDATE Invites SET attend = XXXXX WHERE id = XXXX but I just don't know what to put where or how to get it to do it for each person.
Also I had to change the code for the submit button on page two, it wasnt coming up as a button. I changed it to
Ok, so the page 3 section uses a FOR loop which loops the POSTED values of the drop-down lists. The number of loops is determined by the number of selected lists - that's where count() is useful.
<!--PaGE 3 -->
<?
if(isset($_POST['submit_attend']))
{
//loop through posted selections
for($i=0; $i<count($_POST['attend']); $i++)
{
$attend = $_POST['attend'][$i]; //attending or not (1 or 0 respectively)
$id = $_POST['id'][$i]; //the persons id
if($attend == 1) //this line determines whether a person is attending
{
//update db
//change table_name to your own table's name
//I used field_name as an example and I set it to 1 to indicate that this person is attending
mysql_query("UPDATE table_name SET field_name=1 WHERE id='$id' LIMIT 1");
}
}
}
?>
Is this what you're after?
If you need to update multiple fields then just insert a comma after each value except the last one.