Jump to content

[SOLVED] problem with category and $_get


Guber-X

Recommended Posts

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);
			}

		?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.