[thelist] Trying to write a very simple form to edit a schedule using PHP/MySQL

Dave dave at tokyocomedy.com
Wed Feb 2 09:43:28 CST 2005

The List,
    The Situation:
    I'm trying to create a very simple form where users can add or 
remove dates for an event they've created.

    The Problem:
    I'm stuck as to how to actually get the user selection to actually 
impact the database. It's more a confusion on how to logically organize 
the script than it is about knowing the right commands.

    What I've tried So Far:
    I've got as far as listing the dates already created, with a check 
box beside each entry for users to select to delete if they want. But 
I'm not sure what to do with the data. I know I need to create a MySQL 
command to update the database fields. But I'm lost as to how to 
organize the variables to put the user selected dates into the MySQL 
command line.

    The Question:
    Can anyone suggest what the best way to structure this form to give 
users the ability to remove listed dates?

    For Reference:
    Here is the form so far. I realize it's incomplete, but hopefully it 
will give enough of an idea of what I'm trying to achieve.

<form enctype="multipart/form-data" action="" method="POST">
<p>Scheduled shows</p>
$schedQuery = "SELECT DATE_FORMAT(date, '%W, %b %d, %Y') AS date, date 
AS rawdate FROM schedule WHERE eventid='" . $show . "' AND date >= 
CURDATE() ORDER BY schedule.date";
$schedResult = mysql_query($schedQuery);
$schedData = mysql_fetch_array($schedResult);
while ($schedArray = mysql_fetch_array($schedResult))
    echo "<p>" . $schedArray['date'] . " (Delete? <input 
type=\"checkbox\" name=\"delete" . $schedArray['rawdate'] . "\" 
value=\"rawdate\" />)</p>\n";
<p><input type="submit" name="submit" value="submit" /></p>

    Any advice would be much appreciated.

Dave Gutteridge
dave at tokyocomedy.com

More information about the thelist mailing list