473,471 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Checkbox and relational table

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);
?>
Jul 17 '05 #1
1 1731
Dominique Javet wrote:
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!
<?php require_once('../../../Connections/metadeco_connect.php'); ?> .... $query_rs7client = "SELECT * FROM client ORDER BY libelle ASC";
$rs7client = mysql_query($query_rs7client, $metadeco_connect) or die(mysql_error()); .... if ($totalRows_rs7client>0) {
$nested_query_rs7client = str_replace("12345", $row_rs7client['id'], $query_rs7client);


There's no "12345" in $query_rs7client
That last statement will always do:
$nested_query_rs7client = $query_rs7client;
Instead of (or besides) doing a mysql_query($sql, $connection) do a
print($sql) to check what your script is doing.

(snip rest of code)
I think you should first get your data right (check with print_r());
then put it into HTML with checkbox and whatnot.

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
3
by: Mikey | last post by:
Hi all. In the process of trying to figure this thing out, I've been doing the old "stand around in the store and read as much as possible before you look like a derelict" thing. This time, with...
4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
49
by: Mike MacSween | last post by:
I frequently hear that there isn't a commercially available dbms that fully implements the relational model. Why not? And which product comes closest. Mike MacSween
1
by: Tim Fierro | last post by:
Hello, I have had many years using flat file databases (File Express from way back) but am now at a company where a relational database is needed and would carry us into the future. Since I...
3
by: Robert Abi Saab | last post by:
Hi everyone. I just finished a course on PostgreSQL and I found out that PostgreSQL doesn't provide any object relational features (as claimed in the official documentation), except table...
7
by: Pradeep | last post by:
Hello, I need to take a set of input tables and create an XML output file. The format of the XML output must be user-definable and must be intuitive enough for non-techies to use. input...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.