josephcvh Posted October 10, 2010 Share Posted October 10, 2010 I'm very new to php. I'm still learning slowly. I'm currently doing a page where im showing all my patient records but there's checkboxes to tick and select a particular patient and go to next page.php to see the details of their history. Here is my codings <?php include ("includes/db.php"); ?> <table width="455" align="center" height="129" border="0" cellpadding="0" cellspacing="1"> <tr> <td width="453"><form name="form1" method="post" action="patienthistory.php"> <table width="900" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF" width="100"><strong>Patient ID</strong></td> <td align="center" bgcolor="#FFFFFF" width="200"><strong>Patient Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Patient I/C</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Patient Mobile</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Patient Address</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>City</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>State</strong></td> </tr> <?php $sql = "SELECT patient_id, patient_name, patient_ic, patient_mobile, patient_add, patient_city, patient_state FROM patient_healthcare ORDER by patient_id ASC"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); while(list($patient_id,$patient_name,$patient_ic,$patient_mobile,$patient_add,$patient_city,$patient_state)=mysql_fetch_row($result)){ $checked="$patient_id" ; echo '<tr><td><input name="checkbox[]" type="checkbox" value="'.$patient_id.'" '.$checked.'/></td><td>'.$patient_id.'</td><td>'.$patient_name.'</td><td>'.$patient_ic.'</td><td>'.$patient_mobile.'</td><td>'.$patient_add.'</td><td>'.$patient_city.'</td><td>'.$patient_state.'</td></tr>'."\n"; } ?> When i tick one boxes and press Select. The next page.php shows all the records. I just want a particular record show not all. Need help. Help is appreciated. Quote Link to comment Share on other sites More sharing options...
frizi Posted October 10, 2010 Share Posted October 10, 2010 Welcome on board :] If you wish to select only a specific row, you have to use the following select syntax: $sql = "SELECT UNIQUE patient_id, patient_name, patient_ic, patient_mobile, patient_add, patient_city, patient_state FROM patient_healthcare ORDER by patient_id ASC WHERE patient_id=\'".$_REQUEST['patient_id']."\'"; $_REQUEST['patient_id'] should be the form input or selection so you have to make an selector or input box with name patient_id and a value. This value will be the where search argument. Quote Link to comment Share on other sites More sharing options...
josephcvh Posted October 10, 2010 Author Share Posted October 10, 2010 Thanks for replying! Your reply will be a great help to me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.