PHP - Elseif Statement Not Working
Ok I have a new issue, and for the life of me, I cannot figure out where I went wrong, in my head it looks sound, but it does not seem to really work. I get no errors, but it does not work.
if ($_REQUEST['postal'] != "" && $_REQUEST['lbs'] == "" && $_REQUEST['length'] != "" && $_REQUEST['width'] != "" && $_REQUEST['height'] != '') { } elseif ($_REQUEST['postal'] == "" && $_REQUEST['lbs'] != "" && $_REQUEST['length'] != "" && $_REQUEST['width'] != "" && $_REQUEST['height'] != '') { // THis is the problem right here.... // } elseif ($_REQUEST['postal'] == "" && $_REQUEST['lbs'] == "" && ($_REQUEST['length'] == "" || $_REQUEST['width'] == "" || $_REQUEST['height'] != '')) { } elseif ($_REQUEST['postal'] != "" && $_REQUEST['lbs'] != "" && $_REQUEST['length'] != "" && $_REQUEST['width'] != "" && $_REQUEST['height'] != "") { } else { } The Second elseif is the issue. If I enter the postal and weight, it should go to that if else and execute its code, because I left all the length, height and width blank. But in stead it goes to the last else. What I am looking to do is that if any of the length, width, or height is not entered, then it comes back with an error... But it does not seem to pick up on it. ANy help would be appreciated. [EDIT] I swear I looked at it 50 times and didn't see it... I go and make my post, re-read it and realize my operators were all wrong... [makes action of smaking slef in head] [/EDIT] Similar Tutorials
User Authentication Help By Using If Elseif And Else Statement And Redirect Page On 3 Differnet Urls
i'm having trouble with an elseif statement. its not displaying the result it should ?php if(isset($_COOKIE['ID_forum'])){ $username = $_COOKIE['ID_forum']; $query = "SELECT * FROM users WHERE username = '".$username."'"; $level = mysql_query($query) or die ("Select Error :" . mysql_error()); $userlevel = $level['user_level']; echo $userlevel; if ($userlevel == "1") { echo 'you are a member'; } elseif ($userlevel == "2") { echo 'you are a moderator'; } elseif ($userlevel == "3") { echo 'you are an administrator '; } else echo'you are not logged in'; } ?> it is echoing out 'you are not logged in', when it should be saying 'you are an administrator', as the value in the table is 3. i do know that the cookie 'ID_forum' is there, but i cant find why its not working properly. Any ideas would be great. Thanks Hi My PHP skills aren't that good but I know what I want to do as I have used other programming languages before. I run a WordPress website about a Church and its Cemetery. I have been researching the graves for the last 2 years and have added each grave to the website via a Custom Post Type with the buried occupants. In WordPress I have used a plugin called Advanced Custom Fields and have set each grave to allow at least 5 people buried there. So the following code below is used to check if the fields have any value which would represent each person in that grave and add it to the page. I don't know how to add it as a database table so this is the easiest way I could think of. echo '<div id="section-grave">'; echo "<h3>Who's buried in this Grave?</h3>"; //echo '<p>Listed below, are the people buried in this grave.</p>'; if(get_field('is_burial_date_known')) { // start For Loop for ($x = 1; $x <= 5; $x += 1) { $name_of_deceased = 'name_of_deceased_' . $x; $burial_date = 'burial_date_' . $x; $clergy_name = 'clergy_name_' . $x; if(get_field($name_of_deceased)) { echo '<p>' . $x . ') ' . get_field($name_of_deceased) . '</p>'; } if(get_field($burial_date)) { echo '<p>Burial Date: ' . get_field($burial_date) . '</p>'; } if(get_field($clergy_name)) { echo '<p>Buried By: ' . get_field($clergy_name) . '</p>'; echo '<hr>'; } } // end For Loop } else { echo '<p>Nobody buried here.</p>'; } echo '</div>'; I want to add a paragraph above which I have commented out to show how many people are buried in that grave. So if it was only one person then it should say 1 person as oppose to people. So I need a way of counting the names but I can't see a way how to do it. It will probably based on an IF...Elseif...Else statement and which ever condition is right it just displays the correct line or paragraph. I need a way of counting thetotal number of people per grave but outputting the total relies on the loop which is after the paragraph or line. I hope I have explained it properly so can anyone see how I can do it please? Colin I have this code which checks for the word "Big Ben" and if it's not there it outputs some html. I want t be able to make another statement to also check for the word "London Tower" and if it's not there then to check for the word "Canary Wharf", So far I've only managed one statement without the code breaking, how do I add the others in as well. <?php $astacker=get_post_meta($post->ID, 'thesite', true); if ( $astacker == [b]'Big Ben'[/b]) { ?> <?php include(TEMPLATEPATH."/feedsgrabstack.php");?> <?php }else { ?> <div id="splitter"><div class="clear"> <a href="<?php echo get_post_meta($post->ID, "linktosource", true);?>">Click Here To View Answers</a> <span style="float:right;"><a href="#related">See Related Questions</a></div></div> <?php } ?> Below code is working fine but i need to redirect on 3 different pages and its giving me error. My table structure is as
User table
Email Password
admin@yahoo.com 123
tariq@yahoo.com 987
bilal@yahoo.com 456
if user name is like; admin@yahoo.com the page should redirect on welcome.php
if user name is like; info@aiousoft.com the page should redirect to welcome2.php
and if user doesnot exist in database then give error as ELSE "user doesnot exist"
thanks
signin.php
<html><head><title>Sign In</title></head><body> <?php include 'header.php'; ?> <?php include 'menu.php'; ?> <center> <form method="post" action="checklogin.php"> <h3>Please Signin</h3> <table width="400" border="0"> <tr><td>Email</td> <td><input name="email" type="text" id="email"></td></tr> <tr><td>Password</td> <td><input name="password" type="password" id="password"></td></tr> </table> <p><label> <input type="submit" email="submit" value="Submit"> </label><input email="reset" type="reset"> </p> </form> </center> </body> </html> checklogin.php <html><head><title>Check Login</title></head><body> <?php include 'header.php'; include 'menu.php'; $email=$_POST['email']; $password=$_POST['password']; @ $db = mysql_pconnect('localhost', 'root', ''); if (!$db) { echo 'Error: Could not connect to database. Please try again later.'; exit;} mysql_select_db('car'); $q=mysql_query("select * from user where email='".$email."' and password='".$password."' ") or die(mysql_error()); $res=mysql_fetch_row($q); if($res) { header('location:welcome.php'); } else { echo' Please signin again as your user name and password is not valid'; } ?> </body> </html> Attached Files header.php 284bytes 0 downloads menu.php 308bytes 0 downloads Okay, I have a script that if someone is a particular "class", they can't get additional bonus points for their character. However, if they aren't that class, then they get additional points. But, it seems to be ignoring the elseif and gives a strength point no matter what the class is. I don't see where I coded wrong, so I would appreciate any help! Thanks! if ($expgain + $player->mine_exp >= $player->mine_maxexp) { echo "<br /><b>Your mining leveled up!</b>"; echo "$blurb $randeffect<p>"; if(($strength + $agility + $wisdom + $vitality >=100) && ($class != 'Apprentice' || $class != 'Mage' || $class != 'Priest' || $class != 'Rogue' || $class != 'Scholar' || $class != 'Wanderer' || $class != 'Warrior' || $class != 'Woodsman')) { echo "<br /><b>You gained 1 strength point!</b>"; $query = $db->execute("update `users` set `energy`=?, `mine_level`=?, `mine_exp`=?, `minecount`=?, `strength`=?, `mine_maxexp`=? where `id`=?", array($player->energy - 1, $player->mine_level + 1, $player->mine_exp + 1, $player->minecount + 1, $player->strength + 1, $player->mine_maxexp + $newmax, $player->id)); } elseif (($strength + $agility + $wisdom + $vitality >= 100) && ($class = 'Apprentice' || $class = 'Mage' || $class = 'Priest' || $class = 'Rogue' || $class = 'Scholar' || $class = 'Wanderer' || $class = 'Warrior' || $class = 'Woodsman')) { echo "You have already maxed out your stats at 100!"; $query = $db->execute("update `users` set `energy`=?, `mine_level`=?, `mine_exp`=?, `minecount`=?, `mine_maxexp`=? where `id`=?", array($player->energy - 1, $player->mine_level + 1, $player->mine_exp + 1, $player->minecount + 1, $player->mine_maxexp + $newmax, $player->id)); } elseif($strength + $vitality + $wisdom + $agility < 100) { echo "<br /><b>Your mining leveled up and you gained 1 strength point!</b>"; $query = $db->execute("update `users` set `energy`=?, `mine_level`=?, `mine_exp`=?, `minecount`=?, `strength`=?, `mine_maxexp`=? where `id`=?", array($player->energy - 1, $player->mine_level + 1, $player->mine_exp + 1, $player->minecount + 1, $player->strength + 1, $player->mine_maxexp + $newmax, $player->id)); } } else { $query = $db->execute("update `users` set `energy`=?, `mine_exp`=?, `minecount`=? where `id`=?", array($player->energy - 1, $player->mine_exp + 1, $player->minecount + 1, $player->id)); echo "$blurb $randeffect<p>"; } Hiya, Trying to get this working based on a drop down posted from the step before. Three options are dropoff, collect and ship. This code always defaults to the first option, despite the fact that echoing the session shows the correct choice has been passed through. Here's what I have: Code: [Select] if ($_SESSION['collection'] = "dropoff") { echo "Please drop it off with us"; } elseif ($_SESSION['collection'] = "collect") { echo "Please collect it from me"; } else { echo "Please ship it to you"; } Any ideas what I'm missing here? Thanks! The below code should take you to a different page depending on what you choice in the drop down, but all the results only take you to the first on even when you put a different option in the drop down, any ideas? Code: [Select] <?php ob_start(); session_start(); $pagerank=1; if ($rank < $pagerank){ header('Location:main.php?id=lowrank.php'); } else{ ?> <form action="main.php?id=search.php" method="post"> <table width="725" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="228">Name: <input name="name" type="text" /></td> <td width="490"><select name="type"> <option>All</option> <option>Alliance</option> <option>Corporation</option> <option>Pilot Name</option> <option>Ship Name</option> <option>Ship Type</option> <option>System Name</option> <option>System Type</option> </select></td> </tr> <tr> <td></td> <td><input name="Submit" type="Submit" /></td> </tr> </table> </form> <?php if (isset($_POST['Submit'])) { $name = $_POST['name']; $type = $_POST['type']; if ($type = "System Name" OR "System Type") { header('Location:main.php?id=searchsystem.php'); exit; } Elseif ($type = "All") { header('Location:main.php?id=searchall.php'); exit; } Else { header('Location:main.php?id=searchpilot.php'); } } } ?> PHP newb here - apologies if the answer to this is really simple.
I've tried to add a geotargetting code into my website but it appears the elseif part isn't working, no matter what I do.
Here's the code - any idea why if is fine, and else is fine, but elseif isn't?
<?php if (function_exists('showCountryContentInPage')) { if(showCountryContentInPage(array("us", "ca"),1)) { // US $region = 'USA'; $country = codediesel_get_users_country(); $store_url = 'URL here'; } elseif(showCountryContentInPage(array("at", "es", "cy", "fi", "ee", "fr", "de", "el", "ie", "it", "mt", "lu", "lv", "nl", "pt", "sk", "si", "be"),1)) { // Europe $region = 'Europe'; $country = codediesel_get_users_country(); $store_url = 'URL here'; } else { // UK $region = 'UK'; $country = codediesel_get_users_country(); $store_url = 'URL here'; } ?> I'm having issues with the following: Code: [Select] <?php session_start(); $_SESSION['username']=$_POST['username']; $_SESSION['password']=$_POST['password']; if($_SESSION['username']=="username" && $_SESSION['password']=="password"){ if($_GET['product']=="add"){ $content.=' <p><label>Product Name:</label> <input type="text" name="product_name" size="30" /> <label>Product Price:</label> <input type="text" name="product_price" size="5" /> </p> <p><label>Product Category:</label> <input type="text" name="product_category" size="30" /></p> <p><label>Product Link:</label> <input type="text" name="product_link" size="30" /></p> <p><label>Product Image:</label> <input type="text" name="product_image" size="30" /></p> <p><label>Product Tag:</label> <input type="text" name="product_tag" size="30" /></p> <p><label>Product Keywords:</label> <input type="text" name="keyword" size="30" /></p> <p><label>Product Features:</label><br /> <textarea name="product_features" rows="10" cols="60"></textarea> </p> <p><label>Product Pros:</label><br /> <textarea name="product_pros" rows="5" cols="30"></textarea> </p> <p><label>Product Cons:</label><br /> <textarea name="product_cons" rows="5" cols="30"></textarea> </p> <p><label>Product Description:</label><br /> <textarea name="product_description" rows="10" cols="60"></textarea> </p> <p><label>Product Notes:</label><br /> <textarea name="product_notes" rows="5" cols="30"></textarea> </p> '; $logout='<div><a href="./acp_admincp.php?log-out">Log-Out</a></div>'; } elseif($_GET['product']=="view"){ } else{ $content.=' <a href="./admincp.php?product=add">Add New Product</a> <br /> <a href="./admincp.php?product=view">View Products</a> '; } } elseif(isset($_GET['log-out'])){ session_start(); session_unset(); session_destroy(); header("Location: ./admincp.php"); } else{ $content=' <form action="./admincp.php" method="post"> <p><label>Username:</label> <input type="text" name="username" size="30" />'; $content.='</p> <p><label>Password:</label> <input type="password" name="password" /></p>'; $content.='<p><input type="submit" value="Submit" name="Submit" /></p> </form>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <base href="http://ghosthuntersportal.com/" /> <title>Ghost Hunter's Portal - Admin Control Panel</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="verify-v1" content="" /> <meta name="keywords" content="ghost, hunters, hunter, ghosts, spirit, spirits, paranormal, investigation, investigator, investigators, k2, emf, meter, kii" /> <meta name="description" content="Ghost Hunters Potal. Parnormal research equipment store." /> <meta name="author" content="Andrew McCarrick" /> <meta name="robots" content="index, follow" <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <img src="./logo.png" alt="Ghost Hunter's Portal Admin Control Panel" /> <br /> <div style="color: #AA44AA; font-size: 26px; margin-top: -30px; margin-left: 125px;">Admin Control Panel</div> <?php echo $logout; echo $content; ?> </body> </html> I can log-in, and get to the page with the two links on it. However, once I click one of the links it falls back to the log-in page, and it ends up being a never ending loop. It's doing this: Log-In --> Page with links ---> Log-In page again Should be doing this: Log-In --> Page with links --> Add Product page or View Products page I can never get into the the actual sub page. Just to be clear, the address bar actually shows product=add or product=view, but it still shows the log-in page. Absolutely no idea why my IF statement's playing up - needs some fresh eyes I think! if ($postcheck != $post){ if ($x == "0"){ echo $title; echo "<br>"; $x = "1"; $y = $y + 1; } echo "Change Post to: "; echo $postcheck; echo " from "; echo $post; echo "<br>"; $result2 = mysql_query("UPDATE items SET Post='$postcheck' WHERE ID='$id'") or die(mysql_error()); } When it returns $postcheck and $post, in this case, they're coming out as the same thing (on one record - no others!) - $post is retrieved from a database, and $postcheck is calculated. Both are numbers. Any ideas?! Ok, a bit of a background into my code, It runs off of 2 different passing variables, I have it set up with multiple if() statements to do certain things based on the inputs... Here is a snipet of my code if ($_REQUEST['postal'] != "" && $_REQUEST['lbs'] != "") { $postal = $_REQUEST['postal']; $lbs = $_REQUEST['lbs']; $type = $_REQUEST['type'] if ($type == "splist") { $ztype = "cansp_zone" ; } else { $ztype = "canmp_zone"; } Obviously not the whole thing, Now what you see is line 18-26 of a 216 line document. The nested if statement is what is causing the problem, I get a "syntax error, unexpected T_IF" on line 22, the "if ($type)" line. Now theoretically, if I did not pass the variables (in which case the primary if statement would be false) It should bypass this whole section, however its not. Any ideas? I am thinking its not actually doing the verification and outputting the error because type is not defined. now i am trying to get this to work it should change the variable if the statement is ture and it not in that and any one help include'db.php'; $sql2=mysql_query("SELECT * FROM site_config WHERE id=1")or die(mysql_error()); while($row2=mysql_fetch_array($sql2)) { $paypal_email=$row2['paypal_email']; $price=$row2['price']; $sandbox=$row2['sandbox']; $account_number=$row2['account_number']; $quantity_1=$row2['quantity_1']; $product=$row2['product']; $return_url=$row2['return_url']; $demo=$row2['demo']; if($sandbox==1) { $link='http://www.sambob.info'; if(empty($sandbox)) { $link='http://www.bob.tdsnet.org'; } echo"$link<br>$sandbox"; } } $sql_my_workers = mysql_query("SELECT * FROM Worker WHERE mem_id='$id'"); $my_workers_result = mysql_num_rows($sql_my_workers); while($get_my_workers = mysql_fetch_array($sql_my_workers)){ $my_worker_firstname = $get_my_workers['firstname']; $my_worker_lastname = $get_my_workers['lastname']; $my_worker_age = $get_my_workers['age']; $my_worker_yearspro = $get_my_workers['yearspro']; $my_worker_promotion = $get_my_workers['promotion']; if ($my_workers_result < 1){ $my_workers = " <p class='text' align='center'>You have not created any workers.</p> "; } else { $my_workers .= " <div class='worker_name' align='center'> <p class='text3' style='font-weight: bold; '>Name</p> <p class='text3'>$my_worker_firstname $my_worker_lastname</p> </div> <div class='worker_age' align='center'> <p class='text3' style='font-weight: bold; '>Age</p> <p class='text3'>$my_worker_age</p> </div> <div class='worker_promo' align='center'> <p class='text3' style='font-weight: bold; '>Promotion</p> <p class='text3'>$my_worker_promotion</p> </div> <div class='worker_contract' align='center'> <p class='text3' style='font-weight: bold; '>Contract</p> <p class='text3'>-</p> </div> <div class='worker_yearspro' align='center'> <p class='text3' style='font-weight: bold; '>Years Pro</p> <p class='text3'>$my_worker_yearspro</p> </div> <div class='line'></div>"; } } // connect to the database include_once ("Scripts/mysql_db_connect.php"); // get free agents $sql_free_agents = mysql_query("SELECT * FROM Worker WHERE mem_id!='$id'"); $free_agents_result = mysql_num_rows($sql_free_agents); while($get_free_agents = mysql_fetch_array($sql_free_agents)){ $free_agent_firstname = $get_free_agents['firstname']; $free_agent_lastname = $get_free_agents['lastname']; $free_agent_age = $get_free_agents['age']; $free_agent_yearspro = $get_free_agents['yearspro']; if ($free_agents_result < 1){ $free_agents = "<p class='text'>There are no free agents.</p>"; } else { $free_agents .= "<div class='fa_name' align='center'> <p class='text3' style='font-weight: bold; '>Name</p> <p class='text3'>$free_agent_firstname $free_agent_lastname</p> </div> <div class='fa_age' align='center'> <p class='text3' style='font-weight: bold; '>Age</p> <p class='text3'>$free_agent_age</p> </div> <div class='fa_yearspro' align='center'> <p class='text3' style='font-weight: bold; '>Years Pro</p> <p class='text3'>$free_agent_yearspro</p> </div> <div class='fa_previouspromo' align='center'> <p class='text3' style='font-weight: bold; '>Previous Promotion</p> <p class='text3'>-</p> </div> <div class='fa_reasonleftpromo' align='center'> <p class='text3' style='font-weight: bold; '>Reason for Leaving</p> <p class='text3'>-</p> </div> <div class='fa_salary' align='center'> <p class='text3' style='font-weight: bold; '>Salary</p> <p class='text3'>-</p> </div> <div class='line'></div>"; } } When I do the if < 1 statement, it comes back blank. The if $my_workers_result comes back as showing 0. So it should do that if statement, but yet it doesn't, its just blank. What am I doing wrong? i have been trying to figure this out for the last hour with no luck i am hopeing some one here can help me the problem is well i really dont know what the problem is but the code should check is the passwords match if they dont it will tell you to reenter your password if(isset($_POST['Submit'])) //isset open { $pass1=$_POST['pass1']; $pass2=$_POST['pass2']; if($pass1 != o) //pass open { echo"<style type='text/css'> <!-- body { background-color: #FFFFFF; } body,td,th { color: #000000; } --> </style></head> <body> <table width='100%' border='1'> <tr> <td><center>Your Password Did Not Match Please Reenter Your Passwrods</center></td> </tr> <tr> <td><form id='form1' name='form1' method='post' action=''> <label>Password <input type='text' name='pass1' id='pass1' /> </label> </td> </tr> <tr> <td> <label>Enter Password Again <input type='text' name='pass2' id='pass2' /> </label> </td> </tr> <tr> <td> <label> <center><input type='submit' name='Submit' id='Submit' value='Submit' /></center> </label> </form> </td> </tr> </table> </body>"; die(); //pass colse } else //pass else open { echo" <form name='redirect'> <center> <font face='Arial'><b>Your Account Has Been Validated You Will Now Be Redirect To The Admin Home Page in<br><br> <form> <input type='text' size='3' name='redirect2'> </form> seconds</b></font> </center> <script> <!-- //change below target URL to your own var targetURL='/test1' //change the second to start counting down from var countdownfrom=5 var currentsecond=document.redirect.redirect2.value=countdownfrom+1 function countredirect(){ if (currentsecond!=1){ currentsecond-=1 document.redirect.redirect2.value=currentsecond } else{ window.location=targetURL return } setTimeout('countredirect()',1000) } countredirect() //--> </script>"; //pass else close } //isset close } Hi there im having trouble with my If statement in that its not doing what it is suppose to do! I have a do loop that and If statament that checks that resultp < results. If it is less then an echo is suppose to happen, but its not. Im getting notice errors: Undefined index: Class1- 4 but nothing is outputted. I checked the records in the database so the condition will happen but nothings happening. Help Code: [Select] <?php do { ?> <?php echo $row_resultp['Class1_totla']; echo ' Class 1'; echo'<br>'; echo $row_resultp['Class2_totla']; echo ' Class 2'; echo'<br>'; echo $row_resultp['Class3_totla']; echo ' Class 3'; echo'<br>'; echo $row_resultp['Class4_totla']; echo ' Class 4'; echo'<br>';echo'<br>';echo'<br>'; echo $row_results['Class1_totlas']; echo ' Class 1'; echo'<br>'; echo $row_results['Class2_totlas']; echo ' Class 2'; echo'<br>'; echo $row_results['Class3_totlas']; echo ' Class 3'; echo'<br>'; echo $row_results['Class4_totlas']; echo ' Class 4'; if ($row_resultp['Class1'] < $row_results['Class1']){ echo 'you need'; echo $row_resultp['Class1'] - $row_results['Class1']; echo 'more'; } if ($row_resultp['Class2'] < $row_results['Class2']){ echo 'you need'; echo $row_resultp['Class2'] - $row_results['Class2']; echo 'more';} if ($row_resultp['Class3'] < $row_results['Class3']){ echo 'you need'; echo $row_resultp['Class3'] - $row_results['Class3']; echo 'more'; } if ($row_resultp['Class4'] < $row_results['Class4']){ echo 'you need'; echo $row_resultp['Class4'] - $row_results['Class4']; echo 'more'; } ?> <?php } while ($row_resultp = mysql_fetch_assoc($resultp) && ($row_results = mysql_fetch_assoc($results))); ?> Hello guys, I am having an issue with my if statement. Basically what I am trying to do is when there are no photos uploaded then enter default image. Like I said doesn't look like my if stmt is working at all.. Any ideas? foreach (glob("temp_photo/$subn*.*") as $filename) { //echo "$filename<br>"; $string = $filename; $filename2 = basename($string); if($filename2 == ""){ $filename2="/images/default.jpg"; } // Insert ad details into mysql $query = "INSERT INTO ads (ad_type,ad_title,ad_body,ad_category,ad_photo,ad_member,ad_status,ad_city,ad_state,ad_zip)VALUES('".$ad_type."','".$ad_title."','".$ad_body."','".$catid."','".$filename2."','".$vname."','".$ad_status."','".$city."','".$state."','".$zip."')"; // Error checking to see if the query was successful $result = mysql_query($query) or die (mysql_error()."in <br>$query" ); what i'm trying to do, is have it so a staff member can mange users i came up with these, but it dosn't show on the page :S if ( isadmin ( $_SESSION['user_id'] ) ): ?> <br /> It seems that you're an admin. You may <a href="manage_users.php" title="manage users">manage users</a> or <a href="admin_settings.php" title="edit site settings">edit site settings</a>. <? if ( ismod ( $_SESSION['user_id'] ) ): ?> <br /> It seems that you're an mod. You may <a href="manage_users.php" title="manage users">manage users</a>. <?php endif; ?> So the issue I'm having here is that when champion_id, contender1_id, contender2_id, and contender3_id values are 0 then it DOES NOT echo Vacant and TBD as it should be, however when they are values other than 0 then it does correctly show the person's name. What am I doing wrong for it to not display the Vacant or TBD? Code: [Select] $query = "SELECT titles.title_name, titles.id, title_champions.champion_id AS champion_id, title_champions.contender1_id AS contender1_id, title_champions.contender2_id AS contender2_id, title_champions.contender3_id AS contender3_id, champion.character_name AS champion, contender1.character_name AS contender1, contender2.character_name AS contender2, contender3.character_name AS contender3 FROM title_champions LEFT JOIN titles ON title_champions.title_id = titles.id LEFT JOIN characters AS champion ON title_champions.champion_id = champion.id LEFT JOIN characters AS contender1 ON title_champions.contender1_id = contender1.id LEFT JOIN characters AS contender2 ON title_champions.contender2_id = contender2.id LEFT JOIN characters AS contender3 ON title_champions.contender3_id = contender3.id ORDER BY titles.title_name"; $result = mysqli_query ( $dbc, $query ); // Run The Query Code: [Select] <?php while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo '<tr><td>' . $row['title_name'] . '</td><td>'; if($row['champion_id'] !== 0){echo $row['champion'];}else{echo "Vacant";} echo '</td><td>'; if($row['contender1_id'] !== 0){echo $row['contender1'];}else{echo "TBD";} echo '</td><td>'; if($row['contender2_id'] !== 0){echo $row['contender2'];}else{echo "TBD";} echo '</td><td>'; if($row['contender3_id'] !== 0){echo $row['contender3'];}else{echo "TBD";} echo '</td><td style="text-align:center;"><img src="img/notepad.png" class="edit" rel="' . $row['id'] . '"/></td></tr>'; } ?> Hello Everyone, From time to time, I get into a situation where my if statements do not give the desired results. I always have to play around with them to get the things working. I'm in same situation right now. I'm guessing that I do not completely understand the logic. If someone can take a look at the code below and tell me what's wrong, it will be greatly appreciated. if($_SESSION['account_type'] != 'internal admin'){ die('<font color="red"><b>Error:</b> This page can only be accessed by internal or super admin.</font>'); break; } elseif($_SESSION['account_type'] != 'super admin'){ die('<font color="red"><b>Error:</b> This page can only be accessed by internal or super admin.</font>'); break; } I have echoed out the $_SESSION['account_type'] and I'm getting "internal admin" but for some reason, I'm getting the error "Error: This page can only be accessed by internal or super admin." Thanks in advance for your help. Jatt Surma $query_rsGetOrderDetails = "SELECT * FROM hd_order WHERE order_by = '$usernameLoggedin' ORDER BY order_id DESC LIMIT 3"; Any ideas? |