belmon Posted January 22, 2013 Share Posted January 22, 2013 Hi I have two tables. The first one "services" contains the services service_id = 1 service = service_one service_id = 2 service = service_two an so on In the other table "orders", I've stored the services that clients have ordered: order_id = 1 server_id = 1 client_id = 54 order_id = 2 service_id = 1 client_id = 54 and so on I retrived the posts, already ordered and placed in the table "orders" So far I have come. <?php $ordered = mysql_query("SELECT * FROM services, orders WHERE services.service_id = orders.service_id AND orders.client_id = '".$_GET['id']."' "); while ($order = mysql_fetch_array($ordered)) { echo ' <tr>'; echo ' <td>'; echo ''.$order['service'].'</td>'; echo ' <td><input type="checkbox"'; if ($order['service_id'] != 0) { echo 'checked = "checked"'; } echo 'name="service" value="'.$order['service_id'].'"></td>'; echo ' </tr>'; } What I need is to retrive a COMPLETE LIST of the services in which the already ordered posts are checked in the checkboxes (I have modified the code to simplify my question) Thanks for any assistance Quote Link to comment Share on other sites More sharing options...
Barand Posted January 23, 2013 Share Posted January 23, 2013 Give the checkboxes name="service[]" so they are posted as an array. To process if (isset($_POST['service'])) { $servList = join (',', array_map('intval', $_POST['service'])); $sql = "SELECT service FROM services WHERE service_id IN ($servList)"; // process query } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.