Jump to content

Need help in checkboxes


josephcvh

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.