Hi everyone, this is my first post here.Sorry if there is a lot here, better safe than uninformed.
I use the current versions of php, and Mysql make my pages dynamic. I use Dreamweaver MX 6.1 to build my pages
I have been looking for a number of days on updating my database with multiple checkboxes through an array. The user selects a row with the checkbox to designate which record is updated. No matter what I do, either my loop does not work correctly, or I get no result at all with these notice errors.
"Notice: Undefined index: txtstudent0 in E:\www\intranet\new\admin_today.php on line 11
Notice: Undefined index: chkstudentdel0 in E:\www\intranet\new\admin_today.php on line 11"
I am using radio boxes to "choose" a php script to execute. Currently, I have a delete script that works fine, and an update that does not.
Here's my form code:
Here's my Delete and Update Code So farCode:<form action="admin_today.php" method="post" name="formstudent" id="formstudent"> <table width="100%" border="0"> <tr align="center" valign="middle"> <td colspan="3" bgcolor="#FFFFCC">This is the information already stored into the database</td> </tr> <?php do { ?> <tr bgcolor="#FFFFCC"> <td align="center" valign="middle"> <input name="chkstudentdel[]" type="checkbox" id="chkstudentdel[]" value="<?php echo $row_rsstudentaffairs['TodayID']; ?>"> </td> <td colspan="2" align="center" valign="middle"> <textarea name="txtstudent[]" cols="60" rows="3" id="txtstudent[]"><?php echo $row_rsstudentaffairs['TodayInfo']; ?></textarea> </td> </tr> <?php } while ($row_rsstudentaffairs = mysql_fetch_assoc($rsstudentaffairs)); ?> <tr align="center" valign="middle" bgcolor="#FFFFCC"> <td>Select your function</td> <td width="44%"><input type="radio" name="goal1" value="1"> Delete Record <input name="goal2" type="radio" value="2"> Update Record</td> <td width="21%"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </form>
Right now I'm getting no changes in my database, can anyone help? I'm not terribly new, or super code guru - I'm right in the middle of everything making sense.Code:<?php if (isset($_POST['goal1'])) //select the radio button delete, then submit { $ids_to_delete = join(',' , $_POST['chkstudentdel']); //sql for deleting follows mysql_query("DELETE FROM tblbcmttoday WHERE TodayID IN ($ids_to_delete)"); } elseif (isset($_POST['goal2'])) //select the radio button update, then submit { for ($i = 0; $i < count($_POST['chkstudentdel']); $i++) // loop that doesn't work mysql_query("UPDATE tblbcmttoday Set TodayInfo = '".$_POST['txtstudent'.$i]."' Where TodayID IN ".$_POST['chkstudentdel'.$i].""); } ?>
Thanks so much



Sorry if there is a lot here, better safe than uninformed.

Bookmarks