Need some serious help, wedding RSVP script
Posted: Mon Aug 10, 2009 10:52 am
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Ok, so let me start off by saying I am in way over my head and really have no idea what I am doing. I have managed to piece together mostly by myself and with a little help from others and almost functioning horribly written piece of code. I have been working on this for 14 hours straight and I really need some help.
What I am doing is this... The wedding guest enters a code and it returns a list of the people in there family who were invited. That list has an option for them to attend or not attend. Up to that point everything is working. What I can not get to work is having it take there answer and update the database.
Part of my problem is the code is so butchered I think it is making it harder for things to work properly.
My db has the following fields: id (a unique id number), num ( a group number, everyone in the family has the same one thats who the list of guests is returned to the user), name (name of the guest), and attend (this needs to be updated by the script with the users option the select, whether they will be there or not)
Thank you for anything you can do for me, hopefully I gave all the info you may need.
This is the working code that the user enters the invite number and is sent to the next page that lists the options
This is the mess of code that doesent work that needs to update the db with there answer
This is the code someone else suggested to get it to update the db but i have no idea what to do with it. i don't know if it will help out.
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Ok, so let me start off by saying I am in way over my head and really have no idea what I am doing. I have managed to piece together mostly by myself and with a little help from others and almost functioning horribly written piece of code. I have been working on this for 14 hours straight and I really need some help.
What I am doing is this... The wedding guest enters a code and it returns a list of the people in there family who were invited. That list has an option for them to attend or not attend. Up to that point everything is working. What I can not get to work is having it take there answer and update the database.
Part of my problem is the code is so butchered I think it is making it harder for things to work properly.
My db has the following fields: id (a unique id number), num ( a group number, everyone in the family has the same one thats who the list of guests is returned to the user), name (name of the guest), and attend (this needs to be updated by the script with the users option the select, whether they will be there or not)
Thank you for anything you can do for me, hopefully I gave all the info you may need.
This is the working code that the user enters the invite number and is sent to the next page that lists the options
Code: Select all
<form method="post" action="confirm.php">
<input type=text name='moo' size=60 maxlength=255>
<input type="submit" value="Enter">
</form>
Code: Select all
<?
mysql_connect("localhost", "xxxxx", "xxxxxx") or die(mysql_error());
mysql_select_db("wedding") or die(mysql_error());
$data = mysql_query("SELECT * FROM Invites WHERE num = " . $_POST['moo'] . "")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
?>
<form method="post" action="send.php">
<table cellspacing='16' cellpadding='0' border='0' >
<?
print ("
<tr>
<td class='form_field' valign='top' align='right'>" . $info['name'] . " </td>
<td>
<select name='ATTEND" . $info['id'] . "'>
<option value=''>- Select -</option>
<option value='1' > Will be attending
<option value='0' >Will not be attending
</select>
</td>
</tr>
");
}
?>
<tr><td colspan=3 align='center'><input type='submit' value='Submit'> <input type='button' value='Cancel' onclick="location.href='/';"></td></tr>
</table>
</form>Code: Select all
foreach ($_POST['attend'] as $pk => $willornot) {
if (true == $willornot) {
//assuming attending BOOLEAN NOT NULL DEFAULT FALSE
$query = 'UPDATE invites SET attending = TRUE WHERE yourUniqueColumn = ' . $pk;
//..
}
}
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: