smithmr8 Posted February 21, 2008 Share Posted February 21, 2008 Hi, Im trying to produce the following link, 'company.php?step=apply&id=1'. This I have managed to do, successfully. The part I am having trouble with is this part.. <?php if($_GET['step'] == 'apply' $ $_GET['id'] == $ID){} ?> I have tried this approach, where $ID is defined before this is created and it works in regards to the URL forming correctly.. but when it comes to the above code, its not grabbing the number and passing the statement completely. Do you know of a way In which I could get a statement like this working with a URL like, 'company.php?step=apply&id=1' ? Thanks, Luke Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/ Share on other sites More sharing options...
Chris92 Posted February 21, 2008 Share Posted February 21, 2008 You are using a $ instead of &&'s <?php if($_GET['step'] == 'apply' && $_GET['id'] == $ID){} ?> Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472821 Share on other sites More sharing options...
smithmr8 Posted February 21, 2008 Author Share Posted February 21, 2008 I've changed that but it still isn't working. $ID Defined <?php $ID = $app_info['applicant']; echo "<td width=\"70\">[<a href=\"company.php?step=accept&id=".$ID."\">Accept</a>][Deny]</td>"; ?> $ID Used <?php if($_GET['step'] == 'accept' && $_GET['id'] == $ID){ echo $ID; } ?> Any Ideas ? Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472826 Share on other sites More sharing options...
duclet Posted February 21, 2008 Share Posted February 21, 2008 Are you sure $ID actually have a value? Try outputting it outside of the if statement to verify. Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472827 Share on other sites More sharing options...
smithmr8 Posted February 21, 2008 Author Share Posted February 21, 2008 Well, when I hover over that link, it displays this: http://www.corporate-ladder.co.uk/company.php?step=accept&id=1 So, Im guessing its got a value. The if-statement just isn't picking it up. Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472830 Share on other sites More sharing options...
Rohan Shenoy Posted February 21, 2008 Share Posted February 21, 2008 Did you try with double quotes? <?php if($_GET['step'] == "apply" && $_GET['id'] == $ID) { } ?> Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472832 Share on other sites More sharing options...
smithmr8 Posted February 21, 2008 Author Share Posted February 21, 2008 Yup. I've tried that, but it doesn't make a difference. Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472835 Share on other sites More sharing options...
Daniel0 Posted February 21, 2008 Share Posted February 21, 2008 Put this code before the if statement and post it's output: var_dump($_GET['step'], $_GET['id'], $ID); Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472843 Share on other sites More sharing options...
smithmr8 Posted February 21, 2008 Author Share Posted February 21, 2008 string(12) "applications" NULL string(1) "1" Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472856 Share on other sites More sharing options...
Daniel0 Posted February 21, 2008 Share Posted February 21, 2008 That means that $_GET['id'] has a value of null. Try to post the rest of the script (unless it's huge). Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472859 Share on other sites More sharing options...
smithmr8 Posted February 21, 2008 Author Share Posted February 21, 2008 <?php include ('header.php'); $company_info = mysql_query("SELECT * FROM company WHERE ID=$x[company]"); $company = mysql_fetch_array($company_info); if($_GET['step'] == 'admin'){ if($company['owner'] == $x['ID']){ echo "<b>Administration Options</b><br><br>"; echo "<a href=company.php?step=applications>Applications</a><br>"; } else { echo "You are not the owner!<br>"; } } elseif($_GET['step'] == 'applications'){ $application = mysql_query("SELECT * FROM application WHERE company=$company[iD] ORDER BY date DESC"); $approw = mysql_num_rows($application); if($approw == 0){ echo "There are no applications"; } else { echo "<b>Applications</b><br><br>"; echo "<table border=\"0\" width=\"100%\">"; echo "<tr>"; echo "<td width=\"70\"><b>Date Sent</b></td>"; echo "<td width=\"60\"><b>Applicant</b></td>"; echo "<td width=\"150\"><b>Application</b></td>"; echo "<td width=\"70\"><b>Options</b></td>"; echo "</tr>"; while ($app_info = mysql_fetch_array($application)){ $user = mysql_query("SELECT * FROM users WHERE ID=$app_info[applicant]"); $user_info = mysql_fetch_array($user); echo "<tr>"; echo "<td width=\"70\">".$app_info['date']."</td>"; echo "<td width=\"60\">".$user_info['username']."</td>"; echo "<td width=\"150\">".$app_info['message']."</td>"; $ID = $app_info['applicant']; echo "<td width=\"70\">[<a href=\"company.php?step=accept&id=".$ID."\">Accept</a>][Deny]</td>"; echo "</tr>"; } echo "</table>"; } var_dump($_GET['step'], $_GET['id'], $ID); } elseif($_GET['step'] == "accept" && $_GET['id'] == $ID){ echo $ID; } else { if($x['company'] == 0){ echo "Your not in a company!<br>"; } else { echo "<font size=3><b>".$company['name']."</b></font><br>"; if($company['owner'] == $x['ID']){ echo "[<a href=company.php?step=admin><font color=FF0000>Administration</font></a>]<br><br>"; } else { echo "<br>"; } echo "<font size=1>Message:</font><br>"; if($company['message'] == ""){ echo "Company Message Has Not Yet Been Set!<br><br>"; } else { echo $company['message']."<br><br>"; } echo "<b>Options</b><br>"; echo "Quit Company<br>"; } } include('footer.php'); ?> I wouldn't call it huge . It just gets confusing if you stare at it too long. Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472868 Share on other sites More sharing options...
smithmr8 Posted February 21, 2008 Author Share Posted February 21, 2008 Solved It. Changed it to.. elseif($_GET['step'] == "accept" && $_GET['id'] == is_numeric($_GET['id'])){ $ID = $_GET['id']; Working Perfectly Now. Thanks. Link to comment https://forums.phpfreaks.com/topic/92292-_get-question/#findComment-472903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.