lional Posted June 6, 2009 Share Posted June 6, 2009 Hi I have 2 tables one has the supplements, and the other has the supplements assigned to a client. I want to create a script that would allow me to edit the clients supplements so I firstly need to pull all of the supplements and then check if the client takes those supplements and then insert the quantities. I have the script but what is happening it is only viewing the supplements that is on the clients file, but I need it to list all the supplements whether he takes them or not. Here is my script so far $query_vit = "SELECT * from supplements WHERE active='1' AND supp_cat = '3' ORDER BY supplement"; $result_vit = mysql_query($query_vit, $conn); while ($row_vit = mysql_fetch_assoc($result_vit)){ $supp_id_out = $row_vit["supp_id"]; $supplement_vit_out = $row_vit["supplement"]; $price_vit_out = $row_vit["price"]; $price_vit_out = rtrim($price_vit_out, "0"); $query_cl_vit = "SELECT * from client_supps WHERE client_id = '$client_out' AND supp_id = '$supp_id_out'"; $result_cl_vit = mysql_query($query_cl_vit, $conn); while ($row_cl_vit = mysql_fetch_assoc($result_cl_vit)){ $qty_out = $row_cl_vit["qty"]; print <<<PRICES <tr> <td valign="top" align="center" width="80"> <font face="arial" size="2"><input type="text" size="6" name="product[$supp_id_out]" value="$qty_out"></td> <td valign="top" width="430"> <font face="arial" size="2"> $supplement_vit_out </td> <td align="left" width="140"><font face="arial" size="2"> R $price_vit_out</td> <td valign="top" align="center" width="80"> <font face="arial" size="2"><input type="checkbox" size="6" name="opt[$supp_id_out]" value="1" checked></td> </tr> PRICES; } } ?> Thanks in advance Link to comment https://forums.phpfreaks.com/topic/161174-pulling-data-from-2-tables-in-mysql/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.