Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: PHP Help

  1. #1
    New Coder
    Join Date
    Jul 2009
    Posts
    68
    Thanks
    1
    Thanked 1 Time in 1 Post

    PHP Help

    Hey,

    My code is below:

    PHP Code:
    <?php
    $cat 
    $_GET['offers'];
    if(
    $cat == ""){
    $SearchResult mysql_query("SELECT * from offers ORDER BY `title` ASC LIMIT " . ($page-1)*$Limit ",$Limit") or die(mysql_error());   
    }else{
    $SearchResult mysql_query("SELECT * FROM offers WHERE categoryID = '$cat' LIMIT " . ($page-1)*$Limit ",$Limit") or die(mysql_error());
    }
    while(
    $list mysql_fetch_array$SearchResult )){
          
    $textotemplate = new TextOfferReplace;
          
    $textotemplate->load("template/includes/offershtml.php");
          
    $textotemplate->replace("oid"$list['id']);
          
    $textotemplate->replace("uid"file_get_contents ("template/includes/userid.php"));
          
    $textotemplate->replace("title"$list['title']);
          
    $textotemplate->replace("link"$list['link']);
          
    $textotemplate->replace("offercredit"$list['amount']);
          
    $textotemplate->replace("image"$list['image']);
          
    $textotemplate->replace("credittime"$list['credittime']);
          
    $textotemplate->replace("description"$list['description']);
          
    $textotemplate->replace("requirements"$list['requirements']);
          
    $textotemplate->publish();
    }
    ?>
    I would it so that when offercredit is called it uses the code below instead of $list['amount'].

    PHP Code:
    <?php 
    $data 
    mysql_fetch_array($SearchResult);
       
    $amount $data['amount'];   
          switch (
    $amount) {
          case 
    "1.00":
             echo 
    "1";
          break;
          case 
    "0.50":
             echo 
    "1/2";
          break;
          case 
    "0.30":
             echo 
    "1/3";
          break;
          case 
    "0.25":
             echo 
    "1/4";
          break;
          case 
    "0.20":
             echo 
    "1/5";
          break;
          case 
    "0.16":
             echo 
    "1/6";
          break;
          case 
    "0.14":
             echo 
    "1/7";
          break;
          case 
    "0.12":
             echo 
    "1/8";
          break;
          case 
    "0.10":
             echo 
    "1/9";
          break;

             } 
    ?>
    How could I do this?

    I've tried using
    PHP Code:
    $textotemplate->replace("offercredit", include('offerweights.php')); 
    with the code above in offerweights.php. It works however it includes it on the actual file rather than replacing #offercredit#

    Thanks.
    Last edited by Skippy; 03-09-2010 at 05:38 PM.

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Start with #2 from the forum guidelines:
    2) Type in a subject that summarizes your question- A great way to turn off other members wanting to help you is to type an incomplete or silly subject for your post. Examples of poor subject titles include:

    - "Help!"
    - "I'm a newbie...be gentle"
    - "How can I..."
    - "Urgent...deadline tomorrow!"

    The above subjects either have absolutely nothing to do with the question itself, or are grossly incomplete (ie: "How can I..."). When asking for help, enter a subject that summarizes your question, period! Don't use silly, incomplete, or "bait" subjects. Some examples of good titles are:

    - "How do I round a number to 2 decimal places using JavaScript?"
    - "What's the difference between require() and include() in PHP?"
    - "Can someone suggest a good, free HTML editor?"
    Then, consider using a function's return value as your repalcement.
    Are you a Help Vampire?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •