drews1f
11-15-2006, 05:53 PM
Hello I wonder if anyone can help me.
I currently have a database which holds information about a financial services companies clients. I want to pull a list of all the clients who are married into a drop down box so you can look at their client records together.
So i need to sort out from the database all the client records that have a number in 'client_rel_id'. This corresponds to the 'client_id' of their husband or wife and vice versa.
The problem with my existing code:
<select name="couple_id">
<?
$editlistq = "SELECT * FROM client WHERE client_rel_id =! '' ORDER BY client_surname ASC";
//echo $editlistq;
$editlistre = mysql_query($editlistq);
$editlistrow = mysql_fetch_array($editlistre);
do{
$client_id = $editlistrow[0];
$client_name = $editlistrow[1];
$client_surname = $editlistrow[2];
?>
<option value="<?=$user_name?> <?=$user_surname?>">
<?=$user_name?> <?=$user_surname?>
</option>
<?
}while($editlistrow = mysql_fetch_array($editlistre));
?>
<option selected="selected">
<?=$client_adviser?>
</option>
</select>
Whats above is wrong and stolen from another bit of my code. But basically I can pull out the information as couples and present it in the drop down box.
BUT records are replicated.
ie: client 1, 2 and 5 are single
client 3 and 4 are married
using my code above i get the following output:
1
2
3 & 4
4 & 3
5
I need to get rid of the replication (ie '4 & 3').
I have been told this should be done using a multidimensional array to loop through the records setting client_ids to (-1) if they appear previously as a client_rel_id.
Could someone give me some rough code or a link to a tutorial which will show me how i can make an array from my mysql database?
Thanks to anyone that can help!!!! :)
AR
I currently have a database which holds information about a financial services companies clients. I want to pull a list of all the clients who are married into a drop down box so you can look at their client records together.
So i need to sort out from the database all the client records that have a number in 'client_rel_id'. This corresponds to the 'client_id' of their husband or wife and vice versa.
The problem with my existing code:
<select name="couple_id">
<?
$editlistq = "SELECT * FROM client WHERE client_rel_id =! '' ORDER BY client_surname ASC";
//echo $editlistq;
$editlistre = mysql_query($editlistq);
$editlistrow = mysql_fetch_array($editlistre);
do{
$client_id = $editlistrow[0];
$client_name = $editlistrow[1];
$client_surname = $editlistrow[2];
?>
<option value="<?=$user_name?> <?=$user_surname?>">
<?=$user_name?> <?=$user_surname?>
</option>
<?
}while($editlistrow = mysql_fetch_array($editlistre));
?>
<option selected="selected">
<?=$client_adviser?>
</option>
</select>
Whats above is wrong and stolen from another bit of my code. But basically I can pull out the information as couples and present it in the drop down box.
BUT records are replicated.
ie: client 1, 2 and 5 are single
client 3 and 4 are married
using my code above i get the following output:
1
2
3 & 4
4 & 3
5
I need to get rid of the replication (ie '4 & 3').
I have been told this should be done using a multidimensional array to loop through the records setting client_ids to (-1) if they appear previously as a client_rel_id.
Could someone give me some rough code or a link to a tutorial which will show me how i can make an array from my mysql database?
Thanks to anyone that can help!!!! :)
AR