Jump to content

bzenker

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bzenker's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks to everyone.. I was able to get the code working.. I will be back with more questions in the future. //besides connecting to the database the code below.. a bit messy so will clean up but working as expected. <table width="300" border="0"><tr><td width="30"></td><td><b><u>Start Time</u></b></td><td width="30"></td><td><b><u>End Time</u></b></td></tr></table> <form action="<?=$_SERVER['reserveclientfinal18.php'];?>" method="post"> <table width="500" border="2"> <tr> <td> <?php $query5 = "SELECT chair_appointments.starttime, chair_appointments.endtime, chair_companies.name, chair_appointments.resid from chair_appointments, chair_companies where chair_appointments.scheduleid = chair_companies.scheduleid ORDER BY starttime ASC"; $result2 = mysql_query($query5) or die(mysql_error()); $num2=mysql_numrows($result2); //means if at least one check box is selected $i=0; while ($i < $num2) { $variable1=mysql_result($result2,$i,'starttime'); $variable2=mysql_result($result2,$i,'endtime'); $variable3=mysql_result($result2,$i,'name'); $variable4=mysql_result($result2,$i,'resid'); $i++; $result1=$variable1; $result3=$variable2; $result4=$variable3; $result5=$variable4; if ( $variable2 >= '782') { ?> <table width="350" border="1"> <tr> <td><div align="center"><input type=checkbox name='timeslot[]' value="<?php echo ($result5); ?>"></div></td> <td><input type="hidden" name="starttime[<? echo date('i:s A', $result1-720);?>]" id="starttime" value="<? echo date('i:s A', $result1- 720); ?>"><?php echo date('i:s A', $result1-720); ?></td> <td><input type="hidden" name="endtime[<? echo date('i:s A', $result3-722);?>]" id="endtime" value="<? echo date('i:s A', $result3-722); ?>"><?php echo date('i:s A', $result3-722); ?></td> <td><input type="hidden" name="name[<? echo ($result4);?>]" id="name" value="<? echo ($result4); ?>"><?php echo ($result4); ?></td> </tr> </table> <?php } } ?> </td> </tr></table><table><tr><td colspan="3"><input type="submit" value="Update" /></td></tr></table> </form> <?php $_POST['timeslot']; if($_POST['timeslot'] != NULL){ foreach($_POST['timeslot'] as $k => $c){ //<-- prints the EXACT correct information for the sql query to be properly executed. $sql = "UPDATE chair_appointments SET allow_participation=1 WHERE resid = '". $c ."'"; mysql_query($sql) OR die ("The query:<br>" . $sql . "<br>Caused the following error:<br>" . mysql_error()); $i++; } } ?>
  2. //here is the if statement <?php if(sizeof($_POST['box'])) { foreach($_POST['box'] AS $id) { mysql_query("UPDATE chair_appointments SET `allow_participation` = '1' WHERE `resid` = '$id'"); } } ?> //Here is the checkbox part of the form <input type=checkbox name='box[]' value=\"".$row['resid']."\"> //resid is the unique id field in the database for each row of checkboxes.
  3. I created a form that has a bunch of checkboxes on it. I am extracting time information from the database and assigning the times to the checkboxes. I want the user to be able to select as many checkboxes as they wish so they can book a timeslot. As they select a timeslot it needs to mark the database field to a 1 to show that timeslot is taken. I am trying to extract the value for the checkbox from the database unique id field because each time entry in the database has a unique id. My understanding is checkboxes are suppose to have unique values. My question is can I extract the unique id value from the database which gets generated automatically and use it as a value for my checkbox? I haven't done a lot with checkboxes in Php besides build basic forms. I am open to any suggestions as I have been trying to get this to work for the last week. This is the first time I used your forum but looks like a great resource. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.