menios Posted December 1, 2007 Share Posted December 1, 2007 I ve been developing a website for fun my index page is in html and i got a db that contains around 1000 different items.I ve managed to retrieve the data from the db and arrange then with pagination but it s all my items.What i want to do now is connect my category buttons with the specific items from my db.Can anyone advice me on how to do this? Quote Link to comment Share on other sites More sharing options...
Barand Posted December 1, 2007 Share Posted December 1, 2007 try <?php if (isset($_GET['cat'])) { $cat = $_GET['cat']; // for simplicity only. // Don't trust user input - you should pass GET,POST,COOKIE data through a cleanup function $sql = "SELECT * FROM mytable WHERE cat_name = '$cat'"; echo $sql; } ?> <form> <input type="submit" name="cat" value="Widgets"> <input type="submit" name="cat" value="Gizmos"> <input type="submit" name="cat" value="Wotsits"> </form> Quote Link to comment Share on other sites More sharing options...
menios Posted December 1, 2007 Author Share Posted December 1, 2007 Thx for the tip i ll have a go and post back any questions Quote Link to comment Share on other sites More sharing options...
menios Posted December 1, 2007 Author Share Posted December 1, 2007 My main problem here is that my buttons are html <li><a href="category.html"><b>Category1</b></a></li> how can i include the "input" since i m not using a form? Quote Link to comment Share on other sites More sharing options...
Barand Posted December 1, 2007 Share Posted December 1, 2007 My apologies for thinking your buttons were buttons. Lack of clairvoyance can be a real PITA sometimes. Your processing page will need to be .php and not .html. Put the category in the query string <li><a href="category.php?cat=Category1"><b>Category1</b></a></li> Quote Link to comment Share on other sites More sharing options...
menios Posted December 1, 2007 Author Share Posted December 1, 2007 Sorry my explanation wasn't detailed. My idea was to create one html file with an iframe in the middle as a display area left side some nav. buttons (nested lists), right side some search engine and a login. I wanted to keep my pages as few as possible so i ve been trying to use the lists to connect to different parts of the database and display them in the iframe.So just the content of the iframe would change instead of the page. My tables are tbl_product and tbl_category. So when i click Category 1 want the iframe to display all the items that belong to category 1. after naming index.html to index.php what should be my next steps? Quote Link to comment 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.