Hello,
I've a question regarding the checkbox.
I've a formular with a list of clients per work experience. I can have
several clients for a experience. So I have a table for "experience", one
for "client" and a relational table "rel_experience-client".
To retrieve the list of clients per work experience I use the query :
SELECT *
FROM experience, client, rel_experience_client
WHERE experience_ref=experience.id AND client_ref=client.id AND
experience_ref=12345
ORDER BY libelle
How can I retrive this information and add a checkbox on each client if they
are on the experience?
With the solution below, I can't find the ... solution!
Thx a lot for your help,
Regards, Dom
<?php require_once('../../../Connections/metadeco_connect.php'); ?>
<?php
mysql_select_db($database_metadeco_connect, $metadeco_connect);
$query_rs1experience = "SELECT * FROM experience";
$rs1experience = mysql_query($query_rs1experience, $metadeco_connect) or
die(mysql_error());
$row_rs1experience = mysql_fetch_assoc($rs1experience);
$totalRows_rs1experience = mysql_num_rows($rs1experience);
mysql_select_db($database_metadeco_connect, $metadeco_connect);
$query_rs4_rel_experience_client = "SELECT * FROM experience, client,
rel_experience_client WHERE experience_ref=experience.id AND
client_ref=client.id AND experience_ref=12345 ORDER BY libelle";
$rs4_rel_experience_client = mysql_query($query_rs4_rel_experience_client,
$metadeco_connect) or die(mysql_error());
$row_rs4_rel_experience_client =
mysql_fetch_assoc($rs4_rel_experience_client);
$totalRows_rs4_rel_experience_client =
mysql_num_rows($rs4_rel_experience_client);
mysql_select_db($database_metadeco_connect, $metadeco_connect);
$query_rs7client = "SELECT * FROM client ORDER BY libelle ASC";
$rs7client = mysql_query($query_rs7client, $metadeco_connect) or
die(mysql_error());
$row_rs7client = mysql_fetch_assoc($rs7client);
$totalRows_rs7client = mysql_num_rows($rs7client);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body><form name="form1" method="post" action="">
<?php
if ($totalRows_rs7client>0) {
$nested_query_rs7client = str_replace("12345", $row_rs7client['id'],
$query_rs7client);
mysql_select_db($database_metadeco_connect);
$rs7client = mysql_query($nested_query_rs7client, $metadeco_connect) or
die(mysql_error());
$row_rs7client = mysql_fetch_assoc($rs7client);
$totalRows_rs7client = mysql_num_rows($rs7client);
$nested_sw = false;
if (isset($row_rs7client) && is_array($row_rs7client)) {
do { //Nested repeat
?>
<input <?php if
(!(strcmp($row_rs1experience['id'],$row_rs7client['id']))) {echo "checked";}
?> name="checkbox_client" type="checkbox" id="checkbox_client" value="<?php
echo $row_rs7client['id']; ?>">
<?php echo $row_rs7client['libelle']; ?><br>
<?php
} while ($row_rs7client = mysql_fetch_assoc($rs7client)); //Nested
move next
}
}
?>
<br>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
<?php
mysql_free_result($rs1experience);
mysql_free_result($rs4_rel_experience_client);
mysql_free_result($rs7client);
?>