If within if!?!
Posted: Sun Jan 14, 2007 9:27 am
I'm kind of newbie but I'm trying to make a golfsite where I can show pictures of each hole from a certain golfclub based on clubID. I can get the club by using clubinfo.php?clubid=24 in the browser adress, but how do I create links that refreshes the page with the same clubid but then also with a holeid??? To give you an idea what I mean here is some code I'm working with!
So how do I get "hole=2" after the above line and how do I make that happen in my "link1, link2 and link3" links?
and can I put if and ifelse statements within if statements, and if so, how.
Hope that somebody can help.
Code: Select all
<?php
if (($_GET['clubid']) && (is_numeric($_GET['clubid']))) {
$clubid = $_GET['clubid'];
$dbhost = 'localhost';
$dbuser = 'username';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ("Error connecting to mysql: " . mysql_error());
$dbname = 'mydb';
mysql_select_db($dbname);
$query="SELECT * FROM clubs WHERE ClubID='".$clubid."'";
$result=mysql_query($query) or die("Unable to find requested user");
$currUser = mysql_fetch_array($result);
?>
<?php
//18 holes
if($currUser['course_18']=="yes") {
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>';
echo '<table width="60" border="0" cellspacing="0" cellpadding="0"><tr>';
echo '<td><div align="center"><a href="link1">Hole 1</a></div></td>';
echo '<td><div align="center"><a href="link2">Hole 2</a></div></td>';
echo '<td><div align="center"><a href="link3">Hole 3</a></div></td>';
echo '</tr></table>';
echo '</td></tr>';
//Some if & elseif statements here to decide wich picture to show depinding on links!
if...........
echo '<tr><td>Hole 1 image here!</td></tr></table>';
elseif.......
echo '<tr><td>Hole 2 image here!</td></tr></table>';
else.........
echo '<tr><td>Hole 3 image here!</td></tr></table>';
//9 holes
} else($currUser['course_9']=="yes") {
echo "Some code for viewing 9 holes!";
?>and can I put if and ifelse statements within if statements, and if so, how.
Hope that somebody can help.