hello, basically ive got a while loop which brings up bookings dates but i want to send a selected row to a table within the sql table but depending on, one specific field for instance if the name = "tom" i want to send it to the table called tom, i have three tables and three names.
I have got checkboxes so a user can select up2 2checkboxes once they click send it should send data to database im finding this task very difficult so if anybody could help i would be very grateful.

Here is my code;

// 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.'"></td>'.
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td></tr>";

// Close connection ! (please !)
mysql_close($connection);

?>


its all working results show but nothing happens when you click on checkboxes i have used id to make each row unique and i have id in the database table.

If any1 cud help, im really stuck on what 2do next cheers

When you submit the form, see what is getting posted. I think the checkboxes aren't storing any values !
when you submit the form, add print_r($_POST); in the script which process the form variables.

nothing is getting posted can u give me sum info on how to send the rows 2database?? any clue

nope i dnt mean inserting rows, i want the user 2be able 2select two checkboxes and send them 2the database but the records are coming from a database. u can see from my code thats the loop showing data from the database.

umm..

and send them 2the database but the records are coming from a database.

thats what I meant ! insert to a table/send them to the database.

This is how it works. Checkbox is an array. When you select a checkbox, that index of the checkbox array is selected. For example, if there are 5 checkboxes and the user selects 2 and 5, Only, checkbox[1] and checkbox[4] will be posted to the next page.
So, if you print the data of checkbox array using, print_r($_POST[checkboxname]); you can see the values.

:) Cheers.

k mate ill have ago does this go under echo


print_r($_POST[checkboxname]);

Im trying 2add the date but errors keep coming up im new to php, any ideas whats going wrong????

// 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.'"></td>'.
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td></tr>";

print_r($_POST["bookings"]);

$sql = "INSERT INTO InstructorKellyFox VALUES ('.$row.')";
mysql_query($sql);


// Close connection ! (please !)
mysql_close($connection);

?>

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/stud/1/0472547/public_html/Datesavailable.php on line 111

I don't know whats on line 111. Can you post your code within code tags ? Also, { is missing after while loop.

// 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 .'"></td>'.
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td>".
"<td style=\"color:Black\">".$a_row."</td></tr>";



!!----------------------------------------Error starts here
print_r($_POST["bookings"]);


$sql = "INSERT INTO InstructorKellyFox VALUES ('.$row.')";
mysql_query($sql);



// Close connection ! (please !)
mysql_close($connection);
}
?>

ERROR MESSAGE

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/stud/1/0472547/public_html/Datesavailable.php on line 111

print_r($_POST["bookings"]);

You need to put that when the user submits the form (in the script which processes the form!).

You need to put that when the user submits the form (in the script which processes the form!).

k cheers but how can i insert into a specfic table witin the database depending on which name is chosen from the while loop.

example if peter was chosen i want to send him 2 peter table
and if john was chosen i want to send him to the john table i dont understand how to send it??

The id will be posted when the form is submitted. Query the table where you have the ids to get the name of the selected id. Then send him to retrieved name table.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.