pixeltrace Posted July 16, 2007 Share Posted July 16, 2007 hi, i need help, i have a page wherein i need to display the items in jos_providers table but i always get a "no data found" message. initially i have 3 tables jos_classifieds_providers jos_classifieds_providers_categories jos_classifieds_categories. my "id" in jos_classifieds_providers is equal to the "provider" column in my jos_classifieds_providers_categories and each column has its respective "category" value which is another column in jos_classifieds_providers_categories now each category item in jos_classifieds_providers_categories has its respective name in jos_classifieds_categories where the "parent" column is equal to the "category" column in jos_classifieds_providers_categories i am not sure if my query is working since its not displaying any results below is my current code <? include 'db_connect.php'; $view = (isset($_GET['view'])) ? $_GET['view'] : "main"; if ($view == "main"){ echo " <a href='test.php?id=328&view=sub'>Furniture, Fittings and Decor</a><br> <a href='test.php?id=354&view=sub'>Interior Design</a><br> <a href='test.php?id=355&view=sub'>Cleaning and Repairs</a><br> <a href='test.php?id=367&view=sub'>Home Accessories and Appliances</a><br> <a href='test.php?id=381&view=sub'>Home Alterations and Additions</a><br> <a href='test.php?id=388&view=sub'>Architects, Engineering and Construction</a><br> <a href='test.php?id=391&view=sub'>Home Entertainment</a><br> <a href='test.php?id=395&view=sub'>Real Estate Agents</a><br> <a href='test.php?id=397&view=sub'>Property Services</a><br> <a href='test.php?id=401&view=sub'>Garden and Landscaping</a><br> "; } if ($view =="sub"){ $id = $_GET['id']; $uSql = "SELECT * FROM jos_classifieds_categories WHERE parent = '$id' AND published=1"; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found'; }else{ while($uRow = mysql_fetch_array($uResult)){ $name = $uRow["name"]; echo "<a href='test.php?id=$id&view=subview'>$name</a>" . "<br>"; } } } ?> ====================================================<br><br> <? if ($view = "sub"){ $id = $_GET['id']; $uSql = "SELECT * FROM jos_classifieds_providers WHERE `id` IN (SELECT DISTINCT(provider) FROM `jos__classifieds_providers_categories` WHERE `category` IN (SELECT DISTINCT(id) FROM `jos__classifieds_categories` WHERE `parent` = $id) "; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found'; }else{ while($uRow = mysql_fetch_array($uResult)){ $name = $uRow["name"]; echo "$name $address" . "<br>"; } } }elseif ($view = "subview"){ $id = $_GET['id']; $uSql = "SELECT * FROM jos_classifieds_providers WHERE `id` IN (SELECT DISTINCT(provider) FROM `jos__classifieds_providers_categories` WHERE `category` IN (SELECT DISTINCT(id) FROM `jos__classifieds_categories` WHERE `parent` = $id) "; $uResult = mysql_query($uSql, $connection); if(!$uResult){ echo 'no data found'; }else{ while($uRow = mysql_fetch_array($uResult)){ $name = $uRow["name"]; $address = $uRow["address"]; echo "$name $address" . "<br>"; } } } ?> and this is my test page http://mango.resonance.com.sg/myoochi/findit/test.php hope you could help me with this. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/60157-solved-need-help-in-my-query/ Share on other sites More sharing options...
cooldude832 Posted July 16, 2007 Share Posted July 16, 2007 Your error message suggest you don't have a field (index) named id check your tables. Quote Link to comment https://forums.phpfreaks.com/topic/60157-solved-need-help-in-my-query/#findComment-299264 Share on other sites More sharing options...
rameshfaj Posted July 16, 2007 Share Posted July 16, 2007 Can u post us the structure of the tables. Quote Link to comment https://forums.phpfreaks.com/topic/60157-solved-need-help-in-my-query/#findComment-299323 Share on other sites More sharing options...
pixeltrace Posted July 16, 2007 Author Share Posted July 16, 2007 hi, its working now, i just had a type error. thanks so much for the help! Quote Link to comment https://forums.phpfreaks.com/topic/60157-solved-need-help-in-my-query/#findComment-299331 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.