Dear Alls, I have just studied PHP program. Now I have a problem with my website. "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in" And here my code $result = mysql_query("SELECT a.brand_id as brand_id a.product_name as product_name b.brand_name as brand_name FROM product a, supplier b Where (a.brand_id=b.brand_id) AND (brand_id=$_GET[id])");// and (channel=($age)"); The idea is that I will click on item from my website with brand_id=15, all products which have brand_id=15 will be displayed on the screen. Please help me Thks all & happy new year Sam
<?php $brand_id = $_GET['id']; $result = mysql_query("SELECT * FROM supplier WHERE brand_id = $brand_id"); ?> Code (PHP): OR <?php $brand_id = $_GET['id']; $result = mysql_query("SELECT * FROM supplier WHERE brand_id = $brand_id AND channel = $age"); ?> Code (PHP):
New one ( "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in" And here my code $result = mysql_query("SELECT a.brand_id as brand_id a.product_name as product_name b.brand_name as brand_name FROM product a, supplier b Where (a.brand_id=b.brand_id) AND (brand_id=$_GET[id])");// and (channel=($age)"); The idea is that I will click on item from my website with brand_id=15, all products which have brand_id=15 will be displayed on the screen. Please help me Thks all & happy new year Sam
You're not getting that error from the code you posted. Post the full code. Brandon, both of your solutions would error.
$result = mysql_query(" SELECT a.brand_id, a.product_name, b.brand_id, b.brand_name FROM producta AS a LEFT JOIN productb AS b ON (a.brand_id = b.brand_id) WHERE brand_id = $brand_id "); [CODE] OR [CODE=PHP] $result = mysql_query(" SELECT a.brand_id, a.product_name, b.brand_id, b.brand_name FROM producta AS a LEFT JOIN productb AS b ON (a.brand_id = b.brand_id) WHERE brand_id = $brand_id AND channel = $age "); [CODE] For the above to work, both table producta and productb will have to contain the field brand_id with a matching value to join both together. Code (PHP):