Iconate Posted May 26, 2009 Share Posted May 26, 2009 I have read into it, and in order to have a proper function call from a button, you need to have something of this format <form action="<?=$_SERVER['PHP_SELF'];?>" method="post"> <input type="button" name="submit" value="Submit"> </form> then have php at the top of your page <?php if(isset($_POST['submit'])) { foo(); }?> The only problem is, in my code, I have to cut my function short to insert the button I want. I do not know if thats the issue, but my function is not being called. My MySQL statement works, no issue there. <?php //all php code above, DB connections etc... function dataInsert() //Function trying to be called { mysql_query("INSERT INTO b18_3420450_cal.dates (event_id, arena, date, end_date) VALUES ('6', '1', '2009-05-05 11:00:00', '2009-05-05 12:00:00')") or die(mysql_error()); } if(isset($_POST['book'])) // calling dataInsert if book is submitted { dataInsert(); } function timeCompare($tabletime) { global $result; global $q; $available = true; while ($row = mysql_fetch_array($result)) { $qtime = substr($row['date'], 11, 16); if ($tabletime == $qtime) { echo "<td>TAKEN</td>"; $available = false; break; } } if ($available) { echo "<td>"; echo "AVAILABLE - "; ?> <form action="<?=$_SERVER['php_SELF'];?>" method="post"> <input type="submit" name="book" value=" Book Now "> </form> <?php echo "</td>"; } if (mysql_num_rows($result) != 0) { mysql_data_seek($result,0); } } echo "<table border='1'>"; echo "<tr>"; echo "<th>Time</th>"; echo "<th>Availablility for ". $weekday .", ". $q ."</th>"; echo "</tr>"; echo "<tr>"; echo "<td>08:00</td>"; timeCompare("08:00:00"); echo "<tr>"; ... Is what I did legal? Is there a way around it if its not? Because I need the timeCompare function to determine the Availability of the indicated time, if available a user could click the button to sign up for that time Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 26, 2009 Share Posted May 26, 2009 Define legal. Also, I don't understand what you mean by "cut my function short to insert the button I want". Please elaborate on that. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.