Hello I have two tables in my database.
The first one is table disease which look like the above...
And the second is table patient which look like this ...
And I have an edit page where I want to give the user the ability to update his/her diseases. An example is the below..
What I want to do is to check the disease column from the table patient with the column name from the table disease and check that if a data from the table patient is the same with the data from the table disease then check from the checkboxes the same disease.
I tried to find a way to do it by I couldnt Here is my code...
<?php
$sql = "SELECT name FROM disease UNION SELECT disease FROM patient WHERE username='$username'";
$query_resource = mysql_query($sql);
while( $name = mysql_fetch_assoc($query_resource) ):
?>
<span><?php echo $name['name']; ?></span>
<input type="checkbox" name="disease[]" value="<?php echo $name['name']; ?>" /><br />
<?php endwhile; ?>
The way I store the diseases in my database is this...
$disease = implode(",",$_POST["disease"]);
Because a user might have many diseases
Aucun commentaire:
Enregistrer un commentaire