array problem...

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

 



Hello everyone,

I'm new to PHP/MySQL but I know my way around good now.

I have egroupware installed/setup and its running fine.  I want to create a couple of PHP pages that access the mySQL data to report the info in egroupware.  The information in the one table I can access fine.  

Code for that:  

<?php

$db = mysql_connect("HOST", "USERNAME", "PASSWORD");

mysql_select_db("DATABASE",$db);

$result = mysql_query("SELECT * FROM egw_addressbook

WHERE cat_id=10", $db);

if ($myrow = mysql_fetch_array($result)) {

echo "<table border=0>\n";

echo "<img src=file.jpg width="939" height="136">\n";

echo "<BR>\n";

echo "<BR>\n";

echo "<BR>\n";

echo "<BR>\n";

echo "<BR>\n";

do {

printf("<tr> <td></td><td><b>%s</b></td><td></td><td></td><td></td><td>%s %s</td></tr>\n", $myrow["org_name"], $myrow["n_given"], $myrow["n_family"]);

printf("<tr> <td></td><td>%s</td><td> </td><td></td><td></td><td>%s</td></tr>\n", $myrow["adr_one_street"], $myrow["tel_work"]);

printf("<tr> <td></td><td>%s, %s %s</td><td></td><td></td><td></td><td></td></tr>\n", $myrow["adr_one_locality"], $myrow["adr_one_region"], $myrow["adr_one_postalcode"]);

printf("<tr> <td></td><td></td><td></td><td></td><td></td><td></td></tr>\n");

printf("<tr> <td></td><td></td><td></td><td></td><td></td><td></td></tr>\n");

printf("<tr> <td></td><td></td><td></td><td></td><td></td><td></td></tr>\n");

} while ($myrow = mysql_fetch_array($result));

echo "</table>\n";

} else {

echo "Sorry, no records were found!"; 

}

?>



For what you see there.  It works Great. BUT

There is other info in another table I want to report also in this page.  In the second table one record may have more than one row.  It stays associated with the correct contact with the "contact_id" column matches the "id" column from the first table.  This second table is used for custom fields in egroupware.  



So to do a search for a record in the second table.  its something like:

SELECT contact_value FROM egw_addressbook_extra
WHERE contact_name="Supplier" and contact_id="correct number from first table"

Also valid for Contact_name are:  RANO, Install Date, PrevSystem



When I build the top array I want to include these four other fields but they have to be with the correct record from the first table.



Do I want to do a array merge?

Can I add some ANDs to my current SELECT statement?



I have tried a bunch of stuff can't find a solution.

The bottom line is have it create the array from the first table and then add 4 columns on the end.  then pull the info from the second table and insert it in the last 4 column of the array





Thanks...



Matt




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

  Powered by Linux