Re: Inner Join or 2nd Query...?

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

 



Kristen G. Thorson wrote:

I don't understand what you're trying to do. Do you want two separate list boxes, one for product types and one for makers? If so, use two queries. Use the same block of code you have for product types to populate the makers box. If that's not what you're looking for, you need to describe what your goal is. You might also give more of your table structure since you're asking about joins.


kgt


Mark Sargent wrote:

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@xxxxxxxxxxxxx<p>
Telephone: 03-5209-1777<p>
Fax: 03-5209-2539
</center>
<hr>
</body>
</html>





Hi All,

I'll try this differently(I hope). With the below code, variables are named/set twice ($db, $num, $result, $myrow) etc. In ASP, from what I remember, that would be a no no. Currently, this code only populates the 1st select box. Coupla Qs. Do I have to connect to the db again, in the second block of code..? Should the variables in the 2nd block of code, be named differently to the 1st block.? In ASP the query variables would be named uniquely, identifying to each query like so, prod_query_num, prod_query_result and so forth. I must admit, my recollection of ASP is very vague. Anyway, I hope this explains what I'm looking to understand. Cheers.

Mark Sargent.

<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");
$maker=mysql_result($result,$i,"maker_detail");
$maker_id=mysql_result($result,$i,"maker_id");
echo "<option value=\"$product_type_id\">$product_type</option><br>";
}
?>
</select>
</center>
</td></tr>
</table>
<table align="center" border="2">
<tr>
<td><h3 align=center>Maker</h3></td>
</tr>
<tr><td><center>
<select name="slect_maker">
<?php
$db = mysql_connect("localhost", "root", "grunger");
mysql_select_db("status",$db);
$result = mysql_query("SELECT Makers.maker_id Makers.maker_detail FROM Makers",$db);
$num = mysql_num_rows($result);
for ($i=0; $i<$num; $i++){
$myrow=mysql_fetch_array($result);
$maker=mysql_result($result,$i,"maker_detail");
$maker_id=mysql_result($result,$i,"maker_id");
echo "<option value=\"$maker_id\">$maker</option><br>";
}
?>
</select>
</center>
</td></tr>
</table>
<p>
<p>
<p>
<hr><center>email: ???????????<p>
Telephone:????????<p>
Fax: ?????????
</center>
<hr>
</body>
</html>


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux