Inner Join or 2nd Query...?
| From: | Mark Sargent | Date: | Wed, 11 May 2005 05:00:26 +0000 |
| Subject: | Inner Join or 2nd Query...? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-214899@lists.php.net to get a copy of this message | ||
Hi All,
with wanting to show both product types(Switch, Router etc) and Makers(Cisco, Avaya, etc) on the one page in select boxes, I was wondering, do you use 2 seperate queries to the database or do you inner join to get all in 1..? I have set up different tables with related id's etc. So, to get Products.product_name and Products.product_id along with what the below query pulls, what wold be best..? I believe if I do a 2nd query, than some variables need to be identified with the particular query, yes..? Cheers.
<html>
<body>
<hr>
<h1 align=center>JUMBO STATUS</h1><p>
<center>Used Hardware Specialist</center>
<hr>
<h2 align=center>Admin</h2>
<table align="center" border="2">
<tr>
<td><h3 align=center>PRODUCT TYPE</h3></td>
</tr>
<tr><td><center>
<select name="poduct_type">
<?php
$db = mysql_connect("localhost", "root", "grunger");
mysql_select_db("status",$db);
$result = mysql_query("SELECT ProductTypes.product_type_detail, ProductTypes.product_type_id FROM ProductTypes",$db);
$num = mysql_num_rows($result);
for ($i=0; $i<$num; $i++){
$myrow=mysql_fetch_array($result);
$product_type=mysql_result($result,$i,"product_type_detail");
$product_type_id=mysql_result($result,$i,"product_type_id");
echo "<option value=\"$product_type_id\">$product_type</option><br>";
}
?>
</select>
</center>
</td></tr>
</table>
<p>
<p>
<p>
<hr><center>email: status1@zae.att.ne.jp<p>
Telephone: 03-5209-1777<p>
Fax: 03-5209-2539
</center>
<hr>
</body>
</html>