Jump to content

Retriving data from two tables


belmon

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.