php - Select Data by check box click next and unselect the selected row -
i want create crf form university project . created course table select data course student click completed course , next click .then next page show same data base table not courses, student selected.and student can subset applied courses. when select course , click next, show previous row in course table. want selected course row not select when click . cause completed course not want select applying course.
- i want select row database when aply show same databases row except selected row
i add same line in problem line..
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <title> crf form </title> <link rel="stylesheet" href="css/admin_style.css" > </head> <body> <div id="header"> <a href="index.php"> <h1> welcome crf form </h1> </a> </div> <form action="selection.php" method="post" enctype="multipart/form-data" > <div id=""> <table width="1000" border="5" align="center"> <tr> <td colspan="8" align="center" bgcolor="yellow"> <h1> slect completed course </h1> </td> </tr> <tr bgcolor="orange"> <th> selection: </th> <th> course id: </th> <th> course title: </th> <th> course credits: </th> <th> course statust: </th> <th> delete post: </th> <th> edit post: </th> </tr> <?php include("includes/connect.php"); $query="select * course"; $run=mysql_query($query); while($row=mysql_fetch_array($run)){ $id=$row['id']; $course_id=$row['course_id']; $course_title=$row['course_title']; $course_credits=$row['course_credits']; $course_status=$row['course_status']; ?> <tr align="center" bgcolor="pink"> <td> <input type="checkbox" name="complete[]" value="<?php echo $id; ?>" /> </td> <td> <?php echo $course_id; ?> </td> <td> <?php echo $course_title; ?> </td> <td> <?php echo $course_credits; ?> </td> <td> <?php echo $course_status; ?> </td> <td> <a href="delete.php?del=<?php echo $post_id ?>"> delete </a> </td> <td> <a href="edit.php?edit=<?php echo $post_id ?>"> edit </a> </td> </tr> <?php } ?> <tr> <td align="center" colspan="7"> <input type="submit" name="sub" value="next"> </td> </tr> </table> </form> </div> </body> </html>
this selec.php
<html> <head> <title> crf form </title> <link rel="stylesheet" href="css/admin_style.css" > </head> <body> <div id="header"> <a href="index.php"> <h1> welcome crf form </h1> </a> </div> <div id=""> <table width="1000" border="5" align="center"> <tr> <td colspan="8" align="center" bgcolor="yellow"> <h1> slect completed course </h1> </td> </tr> <tr bgcolor="orange"> <th>selection:</th> <th>course id:</th> <th>course title:</th> <th>course credits:</th> <th>course statust:</th> <th>delete post:</th> <th>edit post:</th> </tr> <?php include("includes/connect.php"); $check=$_post['complete']; foreach($check $ch){ $select= " id!='".$ch."' , ";//here problem } $query="select * course $select id!='0'"; $run=mysql_query($query); while($row=mysql_fetch_array($run)){ $id=$row['id']; $course_id=$row['course_id']; $course_title=$row['course_title']; $course_credits=$row['course_credits']; $course_status=$row['course_status']; ?> <tr align="center" bgcolor="pink"> <td> <input type="checkbox" name="completed" /></input> </td> <td><?php echo $course_id; ?></td> <td><?php echo $course_title; ?></td> <td><?php echo $course_credits; ?></td> <td><?php echo $course_status; ?></td> <td><a href="delete.php?del=<?php echo $post_id ?>">delete</a></td> <td><a href="edit.php?edit=<?php echo $post_id ?>">edit</a></td> </tr> <?php } ?> </table> </div> </body> </html>
i think you're saying once course selected shouldn't displayed on next page student can have on other courses?
if can use following sql query on next page don't want display student's completed course.
select * course id != $course_id
let me know if i'm wrong. didn't comment out reputations low , stackoverflow didn't allow me to.
[edited]
this complete code.
your select php file:
//assuming logging in students username or email id, if store username in session logging in. <?php $user = $_session['username']; include("includes/connect.php"); if (isset($_post['submit'])){ $course_id= $_post['course_id']; $course_title= $_post['course_title']; $course_credits= $_post['course_credits']; $course_status= $_post['course_status']; $query="select course.id,course.title,course.credits,course.status course course.username = $user"; $run=mysqli_query($conn,$query); while($row=mysqli_fetch_array($run)){ $course_id= $_session['course_id'] = $row['course_id']; $course_title=$row['course_title']; $course_credits=$row['course_credits']; $course_status=$row['course_status']; } ?>
now in next php file :
$already_selected_course = $_session['course_id']; query should like. $query = "select course.id,course.title,course.credits,course.status course course.id != $already_selected_course";
this it. note: solution might contain errors of brackets etc logic clear.
for better knowledge have @ mysql complete video series here!
Comments
Post a Comment