<?php
$sql="SELECT * FROM companies as c LEFT JOIN services as s USING(companyid)
ORDER BY c.companyname;";
$res=mysql_query($sql);
if ($res){
    $company_name='';
    while ($ar=mysql_fetch_assoc($res)){
        if ($company_name!=$ar['companyname']) {
            $company_name=$ar['companyname'];
            echo $company_name."<br>\n";
        }
        echo "<li>".$ar['services']."</li>";
    }
}
mysql_free_result($res);

?>

Andrey Hristov
IcyGEN Corporation
http://www.icygen.com
99%

----- Original Message -----
From: "Andrius Jakutis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 24, 2001 5:04 AM
Subject: [PHP-DB] can you help to beginner?


> Hello All,
>
> Maybe you can help me, becouse I was searching for various documentations,
> and it seems too difucult for me, becouse everything is so crowded.
>
> I need to built small html file, where I could get listed companies.
>
> I have two tables in my MYSQL database, companies and services.
> Company table:
> companyid and companyname
>
> services table:
> id companyid services.
>
> So I need simply to get listings like this:
>
> Company name
> services
>
> Company2 name
> Services
>
> etc...
>
> Can you help me? I know that for this example its better to use one table,
> not two, but I am just learning..
>
> Thanks
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to