Jump to content

Search the Community

Showing results for tags 'if statement'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 5 results

  1. if(measure=="feat") { result=(wi*he); if(((wi*he))>0) { result=result; } // alert(result); } if(result=="0") { result ="1"; } This is my code. i want the result as : if the result is between 1-50, it should display 1, similarly 51-100 : 2, 101- 150 : 3, 151-200 : 4.... what code should i write in the result part? anyone help me out. its urgent.
  2. I am a WP and PHP novice still flailing in the deep end of the pool. I am trying to add some logic to display content on certain pages (via WP templates), not on others. I've made some progress but having issues. Here is the plan: On certain pages with an post type of "EVENT" I want content to appear, but not on OTHER pages with an post type of "EVENT". The problem I am running into is that part of the content is appearing on ALL event pages even if they don't meet the criteria. The logic is intended to be this: If the page is post_type "EVENT", AND if the indicated table contains a field with a record CAT which matches the current "POST ID", AND contains a record TYPE which matches value "1", display table cells which contain text "Presented by: ", an href and an image, else display table cells which contain a nonbreaking space. The problem is that the text "Presented by: " is appearing on ALL the even pages, regardless of whether they meet the criteria or not -- which would tend to indicate a problem with the logic code -- but by the same token the href and image are correctly appearing ONLY on the pages that meet the criteria and are NOT appearing on along with the rogue text on pages which do not meet the criteria. I am sure it is a coding error on my part but I am not sure what. ANY help anyone could give would be GREATLY appreciated. The code involved is below (oh, and I should mention that the code in question is in the HEADER.PHP file): <?php if($post->post_type=='event') { $q1=mysql_query("SELECT * FROM table_name WHERE type = 1 AND cat = $post->ID "); $row_diamond=mysql_fetch_object($q1); if ($q1){ ?> <td width="115" align="right" valign="middle" id="diamond1"><strong style="position:relative;bottom:-25px;">Presented by: </strong></td> <td id="diamond2" width="190"> <a href="<?=$row_diamond->website?>" title="<?=$row_diamond->website_title?>" target="_blank" style="cursor:pointer;"><img style="position:relative;bottom:5px;" src="<?php bloginfo('siteurl'); ?>/wp-content/plugins/sean_event/files/<?=$row_diamond->image?>" alt="<?=$row_diamond->alt_text?>"border="0"></a> <br /> </td> <?php } else{ ?> <td width="115" align="right" valign="middle" id="diamond1"> </td> <td id="diamond2" width="190"> </td> <?php } } ?>
  3. OK, I'll keep this short n sweet. Goal: If a specific variable is declared in the URL, assign it to a session and refresh the page without the variable. Here's my code: if(isset($_SESSION['referrer'])){ $referrer = $_SESSION['referrer']; }else{ if(isset($_REQUEST['referrer'])){ $referrer = $_REQUEST['referrer']; }else{ $referrer = $no_referrer; } } $_SESSION['referrer'] = $referrer; if(isset($_REQUEST['referrer'])){ header("Refresh:0, url=/"); } Expected result: If the url http://testsite.com?referrer=abc123 is entered, check for existing session. If it doesn't exist, create one from $_REQUEST['referrer']. Then, check if $_REQUEST['referrer'] exists. If it does, immediately go to the root of the domain (this is located at the root of the domain) so that the url displayed is http://testsite.com instead of the ugly referrer showing. Actual Result: Works great on Chrome, Firefox, Safari, Opera, and Android 4.2.2's web browser, however in IE 8 through IE 11, that code presents an infinite header(); loop. It's executing the header("Refresh:0, url=/"); regardless of whether $_REQUEST['referrer'] is set or not
  4. Hi I am making a code to keep track of hats in my inventory once i click the submit button on my form. I want to make it so that once the amount of hats is zero, I get redirected to outofstock.php. problem is, I get redirected even if the amount of hats is not zero. I tried using.... }elseif($hats == 0){ header("Location:outofstock.php"); ... but I get an error. If I take out the else and just use if, I get no error and the amount is correctly updated...but I also get redirected regardless if the amount of hats is zero or not...can someone please help me out...below is the code...thanks in advance: <?php session_start(); include("functions.php"); connect (); if(empty($_SESSION['uid'])) header("Location:Home.php"); ?> <?php if(isset($_POST['submit'])){ $submit = protect($_POST['submit']); if($submit== ""){ echo "error"; }elseif(strlen($submit) < 6){ echo "error"; }else{ $user_get = mysql_query("SELECT * FROM `inventory` WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error()); $user_get1 = mysql_fetch_assoc($user_get); $hats = $user_get1['hats']; $amount = "1"; $hatupdate = $hats-$amount; $update_stats = mysql_query("UPDATE `inventory` SET `hats`='".$hatupdate."' WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error()); echo $hats; echo "&nbspremaining."; if($hats == 0); header("Location:outofstock.php"); } } ?> <br /> <form action="1.php" method="POST"> <input type = "submit" name="submit" value= "submit" </form>
  5. Hello guys, I have a slight problem with a booking form i made. Booking form is for minicab booking so price calculation is involved. The booking form was working fine with php4 enabled hosting but i have problem with php5 hosting. Script doesnt pass the varible after if conditions are mathced. What happens is, when user selects a pick up address and dropp of address, price should be set in $quotation. The code is below; if ($postcode == "AL1 St. Albans" && $airport == "Heathrow T1" ) { $quotation = 42;} where you see 42 is how much the journey will cost but it doesnt reflect on the final page. I have also tried the following code which works fine; if ($postcode == "AL1 St. Albans" && $airport == "Heathrow T1" ) { echo "42";} Can anyone help me solve this error. Thanks
×
×
  • 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.