combine tow tables orders_and_servies

Codes here !

Moderators: macek, egami, gesf

onadvance
New php-forum User
New php-forum User
Posts: 5
Joined: Mon Nov 07, 2011 10:36 am

combine tow tables orders_and_servies

Postby onadvance » Tue Jan 22, 2013 10:42 am

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

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest

cron