Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Posts posted by HuggieBear

  1. This statement contradicts itself

    PS: I need someone can help me to code this. (don't send me a link to example or something etc...)

    First you say this:

    I need someone can help me to code this.

    This isn't a problem, I've got loads of material that could help you code it.  But then you say this:

    don't send me a link to example or something etc...

    So is what you actually mean "Can you write it for me with me doing nothing?"  >:(

  2. Can't this be done by just using mysql's like?  Obviously this isn't a complete script and you'll need to take the bits and plug them into your script.

     

    // Initial email (Obviously passed into your script via $_POST)
    $email = 'user@gmail.com';
    
    // Get the domain part of the email address
    $domain = substr($email, strpos($email, '@')+1);
    
    // Stick it in a query to the database
    $sql = "SELECT group_name FROM groups WHERE string LIKE '%" . $domain . "%';"
    
    // Run a while loop on the returned results and you should be fine
    

  3. Sorry, my bad, I misread one of your numbers.  Change it to this:

     

    imagefilledrectangle($signature, 100, 15, 250, 30, $red);

     

    It's really simple, the numbers are just offsets from the top left of the image.

     

    In your main image 0,0,350,60 means:

    The top left point should be placed 0 pixels from the left of the screen and 0 pixels from the top of the screen.

     

    In your main image 0,0,350,60 means:

    The bottom right point should be placed 350 pixels from the left of the screen and 60 pixels from the top of the screen.

     

    Exactly the same applies for the filled rectangle, but it's numbers are offset against the parent image.

  4. You need an else statement on your very first conditional.  If you add an else statement to this that exits the script you'll be fine.  The one that says you're not an image or below 20000 bytes.  Or just move all the rest of the code into the first if.

  5. The database is the way to go if you want it truly dynamic.  The database table would contain the image url along with the date it was submitted, then you'd be able to query the database and order the results by the date descending and display using a gallery script that supports pagination.  The other way would be to rename the files on upload based on timestamp and read the directory of images.

     

    It's easy if you know php, but I see from your post that you dont, so you could try googling for a gallery script that can do it, or maybe post in the PHP Freelance board

  6. You've got confused with your if statements.

     

    You have:

    if (isset($_POST["direction"]) == "north")

     

    you need:

    if (isset($_POST["direction"]) && ($_POST["direction"] == "north"))

     

    Basically, what's on the left side of the equals sign must equal what's on the right side, so in your example, you're comparing the left side of the equals sign which is a check to see if the variable is set, if it is return true.  So you're comparing the Boolean TRUE, with the string "north", these obviously aren't the same.

  7. Yes, from the look of the shadowbox-js website, the following code is used to include shadowbox on the page:

    <link rel="stylesheet" type="text/css" href="shadowbox.css">
    <script type="text/javascript" src="shadowbox.js"></script>
    <script type="text/javascript">
    Shadowbox.init();
    </script>

     

    The following should work:

    <?php
    // This is the value that you can switch between 1 and 0
    $show = 1;
    
    if ($show){
       echo '
          <link rel="stylesheet" type="text/css" href="shadowbox.css">
          <script type="text/javascript" src="shadowbox.js"></script>
          <script type="text/javascript">
          Shadowbox.init();
          </script>
       ';
    }
    
    ?>

  8. There's probably a much nicer solution to this but I'm hungover, so this will have to do for now.

     

    <?php
    /* Query to get rates from database goes here, I'm just using hard coded array */
    $rates = array(1 => '4.95', 2 => '6.00', 3 => '8.00', 4 => '5.00', 5 => '15.00');
    
    /* Sample array of id's */
    $products = array(1,2,3,4,4,4,5,6,8,;
    
    /* Build an array of id's keyed on id with a count as the value */
    foreach ($products as $id){
       if (isset($counts[$id])){
          $counts[$id]++;
       }
       else {
          $counts[$id] = 1;
       }
    }
    
    /* Calculate shipping */
    $shipping = 0;
    $flat_rate = 0;
    if (isset($counts[8])){
       $shipping = $rates[5] * $counts[8];
    }
    if (isset($counts[7])){
       $shipping = $shipping + ($rates[4] * $counts[7]);
    }
    if (isset($counts[4]) || isset($counts[3]) || isset($counts[2]) || isset($counts[1])){
       $flat_rate = $rates[1];
    }
    if (isset($counts[5])){
       $flat_rate = $rates[2];
    }
    if (isset($counts[6])){
       $flat_rate = $rates[3];
    }
    
    $shipping = $shipping + $flat_rate;
    
    echo $shipping;
    ?>
    

  9. Found a better way:

    $n = array('81.0', '80.5', '70.5', '70', '71.569', '67.0', '65.5', '90');
    foreach($n as $v)
    {
       echo (ctype_digit($v) ? sprintf('$n = %0.0f', $v) : sprintf('$n = %0.1f', $v)) . '<br >' . PHP_EOL;
    }
    

     

    OUTPUT:

    $n = 81.0
    $n = 80.5
    $n = 70.5
    $n = 70
    $n = 71.6
    $n = 67.0
    $n = 65.5
    $n = 90
    

     

    That doesn't work either.  Look at the first value in the list 81.0, should display as 81, it's the same for 67.0

  10. I can see what you've tried to do there, but it won't quite work as the 'if' condition will always return true.  strstr() will always return the decimal point along with whatever follows it.

     

    I think for want of a better solution, I'll probably go with this.

     

    $n = array('81.0', '80.5', '70.5', '67.0', '65.5');
    
    foreach($n as $v)
    {
       $parts = explode(".", $v);
       echo ($parts[1]) ? $v : $parts[0];
       echo "<br />\n";
    }

     

    Cheers

    Rich

  11. I've been wracking my brain trying to figure this simple problem out and I can't for the life of me figure out the best way to do it.

     

    I have the following array:

     

    $n = array('81.0', '80.5', '70.5', '67.0', '65.5');

     

    I only want to display the numbers to one decimal place if it's not a whole number, like so.

     

    81

    80.5

    70.5

    67

    65.5

     

    I've tried looking for a solution with sprintf(), rtrim() and number_format(), but what's the best way to do it?

     

    Regards

    Rich

  12. Good Question...

     

    I'm not sure if it will work on Server 2003.  Here's my instructions for XP.

     

    Start >> Run

    Type mmc and click Ok.

    File >> Add/Remove Snap In >> Add

    Select 'Computer Management' >> Add >> Finish >> Close >> OK

     

    This should now show you the MMC with your local computer.

     

    If this works then let me know.

     

    Huggie

×
×
  • 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.