Jump to content

Recommended Posts

Hi

I'm building photo gallery .. and i got stuck at one point.

 

There is a code..

 


$session=$_GET['session'];
$result = mysql_query("SELECT * FROM session WHERE session='$session' LIMIT 1");
// printing out country of the current session			
while ($row = mysql_fetch_array($result)) {
    echo "	<span class='info1'>";
echo $row['country'];
echo "<br><br></span>";
}

// this is a part im not sure of ..

$row = mysql_fetch_array($result);
$row['country'] = $country;

// printing out all the sessions in current country

$result = mysql_query("SELECT * FROM session WHERE country='$country' ORDER BY year DESC") or die(mysql_error());
while($row = mysql_fetch_array( $result )) 
{
echo "<span class='links1'><A href='ontheroad.php?session=$row[session]'>$row[session]</a></span><br>";
}

 

Wht i want to do is .. when i choose photo session, browser will print the menu -

1st query containg name of the country, based on selected session

2nd query will print all the sessions that are in selected country.

There is no problem to print out country, but i think is something wrong with passing varaible $country

 

What do i do Wrong?

 

Help Please.

 

Nita

Link to comment
https://forums.phpfreaks.com/topic/55063-solved-mysql-based-menu-problem/
Share on other sites

What is this code for?

 

$row['country'] = $country;

 

The First thing is that you have transversed through all the records and so $row I think has to have false value rather than array

 

i.e. $row has value of false

 

The second thing I think you required

 

$country=$row['country'];

 

 

Please check this out if it helps

 

Bye for now

 

CSJakharia

i did manage to get what i wanted.

 

new code:

 

$session=$_GET['session'];
			$result = mysql_query("SELECT country FROM session WHERE session='$session' LIMIT 1");    
			$row = mysql_fetch_array($result);
			echo "    <span class='info1'>";
			echo $row['country'];
			echo "<br><br></span>";
			$result2 = mysql_query("SELECT * FROM session WHERE country='$row[country]' ORDER BY year DESC") or die(mysql_error());    
			while($rows = mysql_fetch_array( $result2 ))     
			{    
			echo "<span class='links1'>
			<A href='ontheroad.php?session=$rows[session]'>$rows[session]</a></span><br>";    
			}

 

Thanks csplrj for advice !

 

Nita

 

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.