jj20051 Posted July 2, 2010 Share Posted July 2, 2010 Ok so I'm writing a script and it requires (as far as I know) two while mysql functions to run correctly. TABLE 1: Stores Category Names TABLE 2: Stores Product Information I'm running a jquery (listed bellow) to list the categories in an <option> tag. The jquery will display whatever is in the <div> tag corresponding to the category id. (aka if box1 is selected it will display the content in the <div id="box1"> tag). The mysql queries are: "SELECT * FROM categories" $catagory_id = $cat['id']; "SELECT * FROM products WHERE category_id='$catagory_id'" The major problem is I can't break apart the select or div tags listed bellow thus I can't run it all in two queries because there are multiple entries (hence why I'm using a while() function to pull data). I know this is a bit complicated to understand, but hopefully you know how to fix this problem so that query #2 can get data by the category id without destroying the html code bellow. What I'm really looking for is a way for php to save the category ids, know what each of them are and then execute the second while function with each saved id after the first one is complete. <select id="thechoices"> <option value="box1">Box 1</option> <option value="box2">Box 2</option> </select> <div id="boxes"> <div id="box1"><p>Box 1 stuff...</p></div> <div id="box2"><p>Box 2 stuff...</p></div> </div> <script type="text/javascript" src="./includes/jquery.js"></script> <script type="text/javascript"> $("#thechoices").change(function(){ $("#" + this.value).show().siblings().hide(); }); $("#thechoices").change(); </script> Link to comment https://forums.phpfreaks.com/topic/206571-help-with-multiple-while-functions/ Share on other sites More sharing options...
jj20051 Posted July 2, 2010 Author Share Posted July 2, 2010 is it possible to run two mysql queries in one while() function? If so that would probably solve my problem. Link to comment https://forums.phpfreaks.com/topic/206571-help-with-multiple-while-functions/#findComment-1080485 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.