12-15-2009, 03:52 PM
12-15-2009, 04:19 PM
Provide the source where you're expiriencing the problem.
Or do you want an example?
Or do you want an example?
12-15-2009, 06:16 PM
more of an example
like kinda what im looking for
is
check boxes each one a differnt class wich is in a database (i have the courses in the database)
user registers taken to this page(have that) and
the selected all the courses there in and hit submit it will sign there user_id to the class_id if that makes sense?
like kinda what im looking for
is
check boxes each one a differnt class wich is in a database (i have the courses in the database)
user registers taken to this page(have that) and
the selected all the courses there in and hit submit it will sign there user_id to the class_id if that makes sense?
12-16-2009, 01:22 AM
Not knowing your database structure it'd be hard to give accurate queries but this is what I'd do:
Then you'd get something like 1|2|4|8|16 as a list of courses associated to each use, that's how I'd arrange it.
PHP Code:
<?php
echo "<form method=\"post\" action=\"\">\n";
$query = mysqli_query($link, "SELECT * FROM `courses`;");
while($course = mysqli_fetch_assoc($query))
{
echo "<input type=\"checkbox\" name=\"courses[]\" id=\"{$course['name']}\" value=\"{$course['id']}\"> <label for=\"{$course['name']}\">{$course['name']}</label>\n";
}
echo "</form>\n";
if($_POST['courses'])
{
$list_of_courses = "";
foreach($_POST['courses'] as $course)
{
$course = htmlspecialchars($course);
$list_of_courses[] = $course;
}
$new_list_of_courses = implode("|", $list_of_courses);
$update = mysqli_query($link, "UPDATE `users` SET `courses` = '{$new_list_of_courses}' WHERE `user` = '{$whatever}';");
}
?>
Then you'd get something like 1|2|4|8|16 as a list of courses associated to each use, that's how I'd arrange it.