Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery causing my php to break
    primarykey
    data
    text
    <p>I'm working on an online booking system, so I have a php script that receives a date and will output an array of possible timeslots that are free on that date. I'm trying to make it so that when closing the datepicker it sends the variables to the file and retrieves the result. At the moment the submit button also leads to the php file, and will show me available slots when I choose a date. The php part works, but when I add events to the datepicker it won't submit any variables to the php file. I think this is also the cause that when I add another load.('input_date.php'); I get the full timeslot list caused by the if(isset... Can anyone tell me why jQuery is ruining my variable posting? Thanks in advance..</p> <pre><code>$(document).ready(function() { $("#dates").load('input_date.php'); $("#datepicker").datepicker({onClose: function() { $.post("input_date.php", $('#datepicker').serialize()); alert(1); }}); }); </code></pre> <p>This is the php file:</p> <pre><code>&lt;?php include('connection.php'); error_reporting(0); $treatment = $_POST['treatment']; $bookdate = $_POST['bookdate']; if(isset($treatment) &amp;&amp; isset($bookdate)){ $exp = explode("-", $bookdate); //determine what day of the week it is $timestamp = mktime(0,0,0,$exp[1],$exp[0],$exp[2]); $dw = date( "w", $timestamp); // sun0,mon1,tue2,wed3,thur4,fri5,sat6 echo $dw."weekday"; //week day echo"&lt;br/&gt;"; //find bookings with same date $q = mysql_query("SELECT BOOK_SLOT_ID FROM BOOKINGS WHERE BOOK_DATE='$bookdate'"); //make array of booking slots $array1 = array(); while ($s = mysql_fetch_array($q)) { $array1[] = $s['BOOK_SLOT_ID']; } $q2 = mysql_query("SELECT SL_ID FROM SLOTS"); //make array of all slots $array2 = array(); while ($s2 = mysql_fetch_array($q2)) { $array2[] = $s2['SL_ID']; } //remove bookings from all slots $arr_res = array_diff($array2, $array1); //make selectable options of results echo "&lt;SELECT&gt;"; foreach($arr_res as $op){ $r = mysql_query("SELECT SL_TIME FROM SLOTS WHERE SL_ID='$op'"); $q3 = mysql_fetch_array($r); echo "&lt;OPTION value=".$op."&gt;".$q3['SL_TIME']."&lt;/OPTION&gt;"; } echo "&lt;/SELECT&gt;"; }else{ $else = mysql_query("SELECT * FROM SLOTS"); echo "&lt;SELECT&gt;"; while($array_else = mysql_fetch_array($else)){ echo "&lt;OPTION value=".$array_else['SL_ID']."&gt;".$array_else['SL_TIME']."&lt;/OPTION&gt;"; } echo "&lt;/SELECT&gt;"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload