SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Simple script misbehaving

    each blue div with a "y" should also have a yellow box, but the opposite is happening and I can't find the mistake.

    See script in action at:http://www.lincolnsrealdeals.com/util3.php

    PHP Code:
    <?php
    include_once "connect_to_mysql.php";
    $result mysql_query("SELECT * FROM stk WHERE (id = 3) OR (id = 4) OR (id = 5) OR (id = 6)") or die(mysql_error());
    while (
    $row mysql_fetch_array($result)) {
      
    $this_loc_only $row['this_loc_only'];
      echo 
    '<div style="height:200px;width:200px;margin:20px;background-color:cyan;">';
      if (
    $this_loc_only == "y") {    
        echo 
    '<h6 style="float:left;margin:-216px 0px 0px 3px;background-color:yellow;width:55px;text-align:center;">This location only.</h5>';
        echo 
    $this_loc_only '</br>';
      }
      echo 
    '</div>';
    }  
    ?>

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That -216 margin might have something to do with it. Please excuse. I forgot to adjust after the copy paste.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So is this solved now?

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes. Thanks for asking.

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On an unrelated note: use a IN() query instead of all those OR's like:

    Code:
    SELECT * FROM stk WHERE id IN(3, 4, 5, 6)
    Also have a look at how to hide the x-powered-by header on your server.

  6. #6
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I love it. Thanks.


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
  •