SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One more PHP Display Question...

    Hi Again...

    On the same script as I was working on... On this line...
    echo "<tr><td>$domain</td><td>$price</td><td>

    How would I get the regular price and then next to it the price divided by 50%? I would like to be able to offer discounts some days that would show the regular price, and next to the the new discounted price. I know how to do it by itself, bt I am not sure how to do it when it is all on the same line.

    Any help would be appreciated...

    Thanks,

    Doug

    -------------script----------
    <?
    mysql_connect("localhost","xxxxxxxx","xxxxxxx");
    mysql_select_db("thedatabase");

    $query = "SELECT * FROM dd_domains WHERE price >= 99 ORDER BY name";
    $result = mysql_query($query);

    echo "<html><body bgcolor=\"#FFFFFF\"><table border=\"0\" align=\"center\" width=\"600\" cellspacing=\"0\" cellpadding=\"2\"><tr><td><b>Domain</b></td><td><b>Price</b></td></tr>";
    while($row = mysql_fetch_array($result))
    {
    $price = $row['priceb'];
    $domain = $row['name'];

    echo "<tr><td>$domain</td><td>$price</td><td><a href=\"mailto:$domain@mywebsite.com?subject=$domain\">Contact Us</a></td></tr>";
    }

    echo "</table></body></html>";

    ?>

  2. #2
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could fetch the price out of the table, and then make a new variable in which you divide this price in two, or do it like this:

    PHP Code:
    $new_var discount $price
    Then the discount should be made 0,7 for example. This will create a 30% discount on the product. Then you can just output the variable like the others.
    Last edited by Mark T.; Oct 5, 2001 at 11:37.

  3. #3
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Worked perfect...
    That one I should have known... I must be tired!

    Thanks again,

    Doug

  4. #4
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem, I am learning from this every day, so I should thank you !

  5. #5
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One more question...

    Do you know how to give every other output line a different background color?

    Thanks,

    Doug

  6. #6
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know there is a PHP-function for that one, I saw it a few weeks ago. Let me try if I can find it .

  7. #7
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That comes up a lot. Look at freakysid's example here:
    http://www.sitepointforums.com/showt...ight=alternate

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


Bookmarks

Posting Permissions

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