Jump to content

Recommended Posts

Hi, i need to extract info and display it. The only thing is i have 2 tables. As you can see below this code works when extracting info from one table.

$query_food = "SELECT * FROM stock WHERE
tariff='$_POST[interest]' AND
prodDesc = 'paygo' ORDER BY tariff";
$result = mysql_query($query_food,$connect)
or die ("query_food: ".mysql_error($connect));

This works as when the user selects a certain tariff the above code selects the correct products. However i also want to do a query using the manufacturer name. But the maufacturer is stated in another table called stock_item. (if i therefore swap manufacturer for tarrif in the above code it wont work as manufacturer is in a different table). So how do i do this?? The tables i have used are:

stock(stockID, colour, modelnum, tariff, pic)
stock_item(modelnum, manufacturer)

Thanks.
Link to comment
https://forums.phpfreaks.com/topic/4266-extracting-info-from-database-using-php/
Share on other sites

I may not understand what you're trying to do, but wouldn't this work? Are you trying to retrieve the manufacturer from when the user selects the tariff? If that's the case, then you'd make a field in your form 'modelnum' and just use:
[code]
$query_man = "SELECT * FROM stock_item WHERE modelnum = $_POST['modelnum']";
$query_man_result = mysql_query($query_food, $connect) or die ("query_man: ".mysql_error($connect));
[/code]
[!--quoteo(post=352289:date=Mar 6 2006, 05:38 PM:name=Pneumonic)--][div class=\'quotetop\']QUOTE(Pneumonic @ Mar 6 2006, 05:38 PM) [snapback]352289[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I may not understand what you're trying to do, but wouldn't this work? Are you trying to retrieve the manufacturer from when the user selects the tariff? If that's the case, then you'd make a field in your form 'modelnum' and just use:
[code]
$query_man = "SELECT * FROM stock_item WHERE modelnum = $_POST['modelnum']";
$query_man_result = mysql_query($query_food, $connect) or die ("query_man: ".mysql_error($connect));
[/code]
[/quote]

No not quite. The user is given a list of options to choose from. These options are now the list of manufacturers (previously they were tariff, thats why before the user selected the tariff and the products under that tariff were displayed). Now the manufacturers are displayed where $_POST['interest'] (interest is the manufacturer selected by the user). So i have to get the manufacturer and display the phones under the manufacturer, only the phone details are in the stock table and the manufacturer is in the stock_item table. The link from the stock table to the stock_item table is via [i]'modelnum'[/i]. Any suggestions??
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.