Re: Help please

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

You can use  LEFT OUTER JOIN
Table1 : software list
Table2 : installed ones

$res=mysql_query("select table1.software_name, table2.software_name  from
table1 left outer join table2 on
table1.software_name=table2.software_name");

Check if there is not a matching record on table 2

while($row=mysql_fetch_array($res)){
echo $row[0]; //print software name
//check if there is a matching record in table 2 display tick
if (!empty($row[1])) display_tick();
}


Hope this helps

Mustafa


----- Original Message ----- 
From: "Benjamin Jeeves" <ben@xxxxxxxxxxxxxxxxxxxxxxxx>
To: <php-db@xxxxxxxxxxxxx>
Sent: Friday, March 05, 2004 1:07 PM
Subject:  Help please


hi all,

I my querying two tables in mysql the first table I query returns a list of
software that I have.

Then I query a second table that show me what is installed on a computer.

I would then like to be able to display the first list but with a tick next
to software installed on a computer.

I have treid with making a function that reuten the full list of software
but can not get it to to work function below.

function software_list(&$software) # Software is a word or it can be empty.

{

$db_search = "SELECT software_name

FROM software_list

WHERE software_name

LIKE '".$software."%'";

$db_result = mysql_query($db_search);

$db_count = mysql_num_rows($db_result);

while($sw_result = mysql_fetch_array($db_result)){

$temp = $sw_result[software_name];

for($i=0;$i<count($temp); $i++){

$sw_list = $temp;

}

return $sw_list;

}

}

But when I go to print the return values in $sw_list all I get is my first
value

so can I get a full list to be return. I have been trying to print it by
using the following

for($i=0; $i<count(software_list($sw_list));$i++){

print software_list($sw_list);

}

If any one can help with the comparing of the two list and then display a
tick next too any match that would be a great help too.

Thank you



Ben

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux