What I need, is a perhaps a loop for PHP.
On the web page prior to this code, people are signing up for courses. The code I have here works for when people sign up for only one course.
Two questons:
How do I enable them to sign up for multiple courses? (the course is defined by either 'course_id'(a numeric value) or 'course_desc'(a letter value)
How do I insert a call to do a check if a person has registered for the course. Each person can only register once: If they have already registered, I need to tell them they have already registered.
Thank you for your brilliant help!!
Here is the code thus far:
<?php
include ("password.inc") ;
mysql_connect ( $hostname, $dbuser, $dbpassword ) ;
mysql_select_db ($database) ;
$query = "select member_id , first_name , last_name , email , user_name, decode(password,'enc') , day_phone from member_corp_coach where type in ('P' , 'B') and user_name = '$user_name' and decode(password,'enc')='$password'" ;
$result = mysql_query ( $query) ;
$counter = 0 ;
while ( $row_array = mysql_fetch_row($result))
{
$person = $row_array[1] . " " . $row_array[2] ;
$counter = $counter+1 ;
break ;
}
if ( $counter == 0 ) {
header("Location:http://www.dare2feel.com/eclasses1.php");
exit ;
}
$query1 = "SELECT * FROM course WHERE '$course_desc1' = course_desc " ;
$result1 = mysql_query ( $query1 ) ;
if ( $result1 == 0 ) {
print ( mysql_error() );
exit;
}
$counter = 0;
while ( $row_array1 = mysql_fetch_row($result1))
{
$id= $row_array1[0];
$price = $row_array1[4] ;
$counter = $counter+1 ;
break ;
}
if ( $counter == 0 ) {
header("Location:http://www.dare2feel.com/eclasses1.php");
exit ;
}
$query = "INSERT INTO course_member ( course_id , member_id , course_reg_date,
member_type , total_amount )
VALUES ( '$id' , '$row_array[0]', sysdate(), 'P', '$price' )" ;
$result = mysql_query ($query) ;
if ( $result == 0 ) {
print ( mysql_error() );
}
?>
FYI: here is the code from the previous webpage for one of the courses:
<input type="checkbox" name="course_desc1" value="101 Healthy Habits">