pixeltrace Posted July 12, 2007 Share Posted July 12, 2007 hi, i need help, i cant figure out how to fix the error. kindly check this page http://mango.resonance.com.sg/myoochi/findit/test.php and this is the code for that page <? include 'db_connect.php' $view = isset($_GET['view']) ? $_GET['view'] : $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'>$name</a>" . "<br>"; } } } ?> hope you could help me with this. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/59639-need-help-in-my-php-code/ Share on other sites More sharing options...
shamilton Posted July 12, 2007 Share Posted July 12, 2007 On line #4 you have: $view = isset($_GET['view']) ? $_GET['view'] : $view="main"; You're missing a parenthesis set and you don't need to do $view = anthing: $view = (isset($_GET['view'])) ? $_GET['view'] : "main"; That should work. Quote Link to comment https://forums.phpfreaks.com/topic/59639-need-help-in-my-php-code/#findComment-296349 Share on other sites More sharing options...
per1os Posted July 12, 2007 Share Posted July 12, 2007 $view = isset($_GET['view']) ? $_GET['view'] : "main"; No need for the $view = "main" just "main" will do. Quote Link to comment https://forums.phpfreaks.com/topic/59639-need-help-in-my-php-code/#findComment-296351 Share on other sites More sharing options...
pixeltrace Posted July 13, 2007 Author Share Posted July 13, 2007 hi, still not working. http://mango.resonance.com.sg/myoochi/findit/test.php i am still getting the same error. 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'>$name</a>" . "<br>"; } } } ?> hope you could help me with this. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/59639-need-help-in-my-php-code/#findComment-296938 Share on other sites More sharing options...
per1os Posted July 13, 2007 Share Posted July 13, 2007 include 'db_connect.php' // your missing a semicolon here. $view = (isset($_GET['view'])) ? $_GET['view'] : "main"; Quote Link to comment https://forums.phpfreaks.com/topic/59639-need-help-in-my-php-code/#findComment-297333 Share on other sites More sharing options...
pixeltrace Posted July 16, 2007 Author Share Posted July 16, 2007 thanks! its working now. i have another question, how can i display the listing result in such a way that i can display the listing result in 2, 3 or 4 columns? currently this is my 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'>$name</a>" . "<br>"; } } } ?> hope you could help me with this. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/59639-need-help-in-my-php-code/#findComment-299211 Share on other sites More sharing options...
pixeltrace Posted July 16, 2007 Author Share Posted July 16, 2007 any help on this please? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/59639-need-help-in-my-php-code/#findComment-299332 Share on other sites More sharing options...
shamilton Posted July 16, 2007 Share Posted July 16, 2007 Well... If you mean "How do I take the results from a SQL query and output them to a screen in columns" then you would probably use a table or CSS. Quote Link to comment https://forums.phpfreaks.com/topic/59639-need-help-in-my-php-code/#findComment-299508 Share on other sites More sharing options...
JayBachatero Posted July 16, 2007 Share Posted July 16, 2007 I think this should do what you want to do. Just need to fix the link and make it point to where you want to. Also change the # of columns. <?php 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>'; } elseif ($view == 'sub') { $id = (int) $_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 { $columns = 3;// How many columns? $counter = 0; // Start the counter. $width = 100 / $columns; // Set the width so that each cell is split up evenly. echo ' <table>'; while ($uRow = mysql_fetch_assoc($uResult)) { // Open up the first row. if ($counter == 0) echo ' <tr>'; // Now for the data for each cell. echo ' <td width="' . $width . '%"><a href="test.php">' . $uRow['name'] . '</a></td>'; // Increase the counter. $counter++; // We have the max # of columns. if ($counter == $columns) { echo ' </tr>'; // Start fresh. $counter = 0; } } // We have some rows to close. if ($counter != 0) { // Lets fill in the missing cells. if ($columns - $counter > 0) { for ($i = 0; $i < $columns - $counter; $i++) echo ' <td width="' . $width . '%"> </td>'; } echo ' </tr>'; } // Close table. echo ' </table>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/59639-need-help-in-my-php-code/#findComment-299739 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.