moonjazz
-
Posts
6 -
Joined
-
Last visited
Never
Posts posted by moonjazz
-
-
is it possible to do that?
example :
IF $ClassSize=$HeadCount THEN UPDATE course SET Status = 'close';
-
-
Hello...
i have done some changes
i do a GET to see whats the value of ClassSize and HeadCount
but each time after i hit the register button
the url shows
http://localhost/xampp/1/conreg.php?radio=COM01&Submit=Register&ClassSize=&HeadCount=
ClassSize and HeadCount has no value...
May i know whats causing the problem ? thanks very much
<html> <head> <title>TimeTable</title> </head> <body> <h1> Here is the timetable</h1> <?php @ $db = new mysqli('localhost', 'root', '', 'mylifestyle'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "SELECT course.CourseCode, course.CourseName , course.Instructor , course.ClassSize , courseschedule.HeadCount , courseschedule.Date ,courseschedule.Time , courseschedule.Location FROM course INNER JOIN courseschedule ON course.CourseID = courseschedule.CourseID"; $result = $db->query($query); $num_results = $result->num_rows; echo "<table border='1'> <tr> <th>CourseID</th> <th>Course Name</th> <th>Instructor</th> <th>HeadCount</th> <th>Class size</th> <th>Date</th> <th>Time</th> <th>Location</th> <th>Register</th> </tr>"; ?> <?php while($row = $result->fetch_assoc()) { ?> <tr> <form name="form1" method="get" action="conreg.php"> <td><? echo $row['CourseCode']; ?></td> <td><? echo $row['CourseName']; ?></td> <td><? echo $row['Instructor']; ?></td> <td><? echo $row['HeadCount']; ?></td> <td><? echo $row['ClassSize']; ?> </td> <td><? echo $row['Date']; ?></td> <td><? echo $row['Time']; ?></td> <td><? echo $row['Location']; ?></td> <td align='center'><input name='radio' type='radio' value=<? echo $row['CourseCode'];?> onClick='document.Submit.formVar.value='.$row['CourseName'].'> </td> </tr> <?php } $db->close(); ?> <td><input type="submit" name="Submit" value="Register"></td> <input type="hidden" name="ClassSize" value="<? echo $row['ClassSize']; ?>"/> <input type="hidden" name="HeadCount" value="<? echo $row['HeadCount']; ?>"/> </form> </body> </html>
-
Thanks for the respond...
i have made some changes but it seems like the database is not updated..
am i doing it right?
Please advice..
<html> <head> <title>TimeTable</title> </head> <body> <h1> Here is the timetable</h1> <?php @ $db = new mysqli('localhost', 'root', '', 'mylifestyle'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "SELECT course.CourseName , course.Instructor , course.ClassSize , courseschedule.Date ,courseschedule.Time , courseschedule.Location FROM course INNER JOIN courseschedule ON course.CourseID = courseschedule.CourseID"; $result = $db->query($query); $num_results = $result->num_rows; echo "<table border='1'> <tr> <th>Course Name</th> <th>Instructor</th> <th>Class size</th> <th>Date</th> <th>Time</th> <th>Location</th> <th>Register</th> </tr>"; ?> <?php for ($i=0; $i <$num_results; $i++) { $row = $result->fetch_assoc();?> <form method="post" action="haha.php"> <tr> <td><? echo $row['CourseName']; ?></td> <td><? echo $row['Instructor']; ?></td> <td><? echo $row['ClassSize']; ?></td> <td><? echo $row['Date']; ?></td> <td><? echo $row['Time']; ?></td> <td><? echo $row['Location']; ?></td> <td align="center"><input name="radio" type="radio" id="radio[]" value="<? echo $row['ClassSize']; ?>"></td> </tr> <?php } ?> <p> <form method="post" action="<?php echo $PHP_SELF;?>"> <td> <input type = "submit" name="reg" value="Register" /></td> <input type = "hidden" name="formVar" value="<?php echo $ClassSize?>" /> </form> </p> </div> </body> </html>
haha.php
<?php if (!empty($_POST['reg'])) { $myvarA = $_POST['formVar']; $ClassSize=$myvarA; //echo "myvarA= "." $myvarA". "</br>"; if (!get_magic_quotes_gpc()) { $ClassSize = addslashes($ClassSize); } @ $db = new mysqli('localhost', 'root', '', 'mylifestyle'); if (mysqli_connect_errno()) { echo "Error: Could not connect to database. Please try again later."; exit; } for($i=0;$i <$num_results;$i++){ $del_id = $radio[$i]; $query = "UPDATE course SET ClassSize = ClassSize -1 Where id='$del_id'"; $result = $db->query($query); if ($result) { echo "u r reg!<br />"; } $db->close(); } } ?>
-
Hi there.
I have this course registering website whereby i will need to :
1. pull out all course info and display (done that)
2. when user choose the course they are interested in using radio button and click submit , it will display you're registered and update the database to decrease the head count by 1.
i m stuck on the radio button part... after i click submit nothing happens...
Please advice... thanks a lot
<html> <head> <title>TimeTable</title> </head> <body> <h1> Here is the timetable</h1> <?php @ $db = new mysqli('localhost', 'root', '', 'mylifestyle'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "SELECT course.CourseName , course.Instructor , course.ClassSize , courseschedule.Date ,courseschedule.Time , courseschedule.Location FROM course INNER JOIN courseschedule ON course.CourseID = courseschedule.CourseID"; $result = $db->query($query); $num_results = $result->num_rows; echo "<table border='1'> <tr> <th>Course Name</th> <th>Instructor</th> <th>Class size</th> <th>Date</th> <th>Time</th> <th>Location</th> <th>Register</th> </tr>"; ?> <?php for ($i=0; $i <$num_results; $i++) { $row = $result->fetch_assoc();?> <tr> <form action = "" method = "post"> <td><? echo $row['CourseName']; ?></td> <td><? echo $row['Instructor']; ?></td> <td><? echo $row['ClassSize']; ?></td> <td><? echo $row['Date']; ?></td> <td><? echo $row['Time']; ?></td> <td><? echo $row['Location']; ?></td> <td align="center"><input name="radio" type="radio" id="radio[]" value="<? echo $row['ClassSize']; ?>"></td> </tr> <?php } ?> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="submit" type="submit" id="submit" value="submit"></td> <?php if($submit){ for($i=0;$i<$num_results;$i++){ $del_id = $radio[$i]; $query = "UPDATE course SET ClassSize = ClassSize -1 Where id='$del_id'"; $result = mysql_query($query); } // if successful redirect to delete_multiple.php if($result){ echo "$CourseName was deleted from database - myliftstyle!!<br />"; // Compute the item costs and total cost } } ?> </div> </body> </html>
[attachment deleted by admin]
if $x=$y then update mysql
in MySQL Help
Posted
i realized
does the same thing.