Guber-X Posted July 11, 2009 Share Posted July 11, 2009 okay, ill try to explain the best i can on what im trying to do. this is for a photo page with categories. the categories are set up with id's under $cat_id. the main page of it will show the categories that are listed in the mysql database. in this case "Snowboard, Skateboard, Skimboard, Moto" each one of those of course has its own "$cat_id" basicly 1-4. now when you click on those categories, i want it to list the pictures in that category. I have this partly working, it seems the last query aka the moto link is the only one that is working. the other three dont work. can anyone help me. the link to the page: http://70.66.236.26/timeless/photos.php heres the php code to the page <? $result = mysql_query("SELECT * FROM photo_cat ORDER by id"); if (!$result) { die("query failed: " . msql_error()); } while ($row = mysql_fetch_array($result)) { list($id, $cat_name, $cat_id, $location) = $row; print(': <a href=photos.php?cat='.$cat_id.' target="_top">'.$cat_name.'</a> :'); } ?> </center> <hr width="350" align="center" /> <? if($_GET["cat"]==$cat_id){ echo($cat_id); } ?> Quote Link to comment Share on other sites More sharing options...
xtopolis Posted July 11, 2009 Share Posted July 11, 2009 for the bottom part it would be something like this: <?php $category = (isset($_GET['cat'])) ? intval($_GET['cat']) : 1; //if a category is set, use it, if not, default to 1 $sql = "SELECT imageReference FROM yourTable WHERE cat_id = $category"; //do mysql query stuff and display the images ?> You would of course add more checking that the category integer is valid, and change the query to match your database. Quote Link to comment Share on other sites More sharing options...
Guber-X Posted July 11, 2009 Author Share Posted July 11, 2009 okay that worked better, but only one category isnt working... and im confused... lol Quote Link to comment Share on other sites More sharing options...
Guber-X Posted July 11, 2009 Author Share Posted July 11, 2009 ah there we go, it works great now. it woulda help if i had something in the database for that category 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.