Hello people i need some help, ive got all the code but having problems making it work.
The webpage which i am creating allows the user to select day and time and when they click search it displays the results and i want the user to be able to select up2 3 bookings ive used checkboxes and got all the code but it dont work i been doing it for abt 2weeks and cant get it to work.

i have used checkboxes in the loop so when a user see's the results the textboxes appear next to it. i dont understand how to insert the selected dates during the while loop so someone please help i have a deadline on saturday.

The file is attached so if anybody could put the code in the right places by the way i am new to php Thank u

  <title>Dates </title>

<script Language="JavaScript">
function checkbox_checker()

// set var checkbox_choices to zero

var checkbox_choices = 0;

// Loop from zero to the one minus the number of checkbox button selections
for (counter = 0; counter < checkbox_form.checkbox.length; counter++)

// If a checkbox has been selected it will return true
// (If not it will return false)
if (checkbox_form.checkbox[counter].checked)
{ checkbox_choices = checkbox_choices + 1; }


if (checkbox_choices > 3 )
// If there were more than three selections made display an alert box 
msg="You're limited to only three selections.\n"
msg=msg + "You have made " + checkbox_choices + " selections.\n"
msg=msg + "Please remove " + (checkbox_choices-3) + " selection(s)."
return (false);

if (checkbox_choices < 3 )
// If there were less then selections made display an alert box 
alert("Please make three selections. \n" + checkbox_choices + " entered so far.")
return (false);

// If three were selected then display an alert box stating input was OK
alert(" *** Valid input of three outfielders was entered. ***");
return (true);


<body bgcolor="White">

<!-----Top menu----->

<table border="0" width="100%">

<div id="underlinemenu">
<li><a href="booklesson2.php" title="Back">Back</a></li>	


 <table border="0" Width="100%">
<td align="left"><img border="0" img src="fastlearner.JPG" Width="230" height="95"></td>
<td align="center"><img border="0" img src="think.gif" Width="100" height="50"></td>
<td align="center"><img border="0" img src="dsa.gif" Width="80" height="50"></td>
<td align="center"><img border="0" img src="ADI.jpg" Width="60" height="60"></td>
<td align="center"><img border="0" img src="DIA.gif" Width="55" height="50"></td>

<table align=center border="0" width="75%">    

<!-----PHP script for connecting php to database----->


// Retrieve value from form
$value1 = $_POST['InstructorName'];
$value2 = $_POST['Bookingdate'];
$value3 = $_POST['DayofWeek'];
$value4 = $_POST['TimeOfDay'];
$value5 = $_POST['TimeOfDayEnd'];
$value6 = $_POST['LessonType'];
$value7 = $_POST['Gearbox'];

// Standard SQL
$sql = "SELECT * FROM Bookingdates WHERE InstructorName LIKE '%$value1%' AND Bookingdate LIKE '%$value2%' AND  DayofWeek LIKE '%$value3%' AND TimeOfDay BETWEEN '$value4' AND '$value5' AND LessonType LIKE '%$value6%'AND Gearbox LIKE '%$value7%'";
echo $sql;

// Connect to DB server
$connection = mysql_connect("", "", "");
if (!$connection)
	die("Cannot connect to DB");

// Select database
mysql_select_db("", $connection)
	or die("Cannot find DB");

// Retrieve the data
$result = mysql_query($sql, $connection);

<table border="0" width="75%"> 
<td><center><hr>Booking date available</center><hr></td>
<td><center><hr>Day of Week</center><hr></td>
<td><center><hr>Time Of Day</center><hr></td>
<td><center><hr>Time Of DayEnd</center><hr></td>
<td><center><hr>Lesson Type</center><hr></td>
<td><center><hr>Gearbox Type</center><hr></td>
<td><center><hr>Instructors Name</center><hr></td> 
<td><center><hr>Cost For Lesson ()</center><hr></td>

// Loop through data and display
while($a_row = mysql_fetch_assoc($result))
echo "<tr>".
	'<td style="color: black;"><input type="checkbox" name="bookings[]" value="'.$a_row['id'].'"></td>'.
	"<td style=\"color:Black\">".$a_row['Bookingdate']."</td>".
	"<td style=\"color:Black\">".$a_row['DayofWeek']."</td>".
	"<td style=\"color:Black\">".$a_row['TimeOfDay']."</td>".
	"<td style=\"color:Black\">".$a_row['TimeOfDayEnd']."</td>".
	"<td style=\"color:Black\">".$a_row['LessonType']."</td>".
        "<td style=\"color:Black\">".$a_row['Gearbox']."</td>".
        "<td style=\"color:Black\">".$a_row['InstructorName']."</td>".
	"<td style=\"color:Black\">".$a_row['CostForLesson']."</td></tr>"; 

// Close connection ! (please !)


<form action="ConfirmDetails.php" method="Post"  

$sql="INSERT INTO InstructorKellyFox (Bookingdate, DayofWeek, TimeOfDay, TimeOfDayEnd, LessonType, Gearbox, InstructorName, CostForLesson)
$result=mysql_query($sql) or die(mysql_error());

onsubmit="return checkbox_checker()" name="checkbox_form">


<input type="submit" value="Submit">

10 Years
Discussion Span
Last Post by sukhy_1
$connection = mysql_connect("", "", "");

What is this line supposed to do, connect to what database ?


yes thats meant to connect to database thats all working ive just taken the connection out has its got username and password. its just im having trouble with inserting the while loop results into the database ive used id and checkboxes which show next to each search output cheers

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.