PHP CREW v.easy stuff

Discussion in 'OT Technology' started by MSTRMOO, Jun 28, 2007.

  1. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    k uhh.. on this link (edit: this link is showing the result of another script right now) http://www.prestigehomedesign.com/flooring.php?cat=1 the items are being displayed vertically.. i need them to be displayed horizontally.. how do i do that?

    heres the script..

    Code:
    <?php
    
    $query = "SELECT * FROM items WHERE";
        
        if (is_numeric($_GET['cat'])) {
            $cat = $_GET['cat'];
            $query .= " category ='$cat'";
            $var = TRUE;
        }
        
        if (is_numeric($_GET['gp1'])) {
            $gp1 = $_GET['gp1'];
            if (!$var) {
                $query .= " grp1 ='$gp1'";
            } else {
                $query .= " AND grp1 ='$gp1'";
            }
            $var = TRUE;
        }
        
        if (is_numeric($_GET['gp2'])) {
            $gp2 = $_GET['gp2'];
            if (!$var) {
                $query .= " grp2 ='$gp2'";
            } else {
                $query .= " AND grp2 ='$gp2'";
            }
            $var = TRUE;
        }
        
    if ($var) { 
            $result = mysql_query($query); 
            if (mysql_num_rows($result) > 0) { 
    		    echo "<table width=\"100%\">";
        		echo "<tr style=\"font-weight: bold;\"><td>Picture</td><td>Color</td>\n";
                while ($fetch = mysql_fetch_array($result, MYSQL_ASSOC)) { 
                    echo "<table width=\"100%\">"; 
                    echo "<tr><td><a href=\"item.php?item={$fetch['id']}&cat={$fetch['category']}\" target=\"_blank\">".thumb(stripslashes($fetch['pic1']) ,stripslashes($fetch['brand']))." </a></td></tr>\n";
                } 
            } else { 
                echo 'No items here.'; 
            } 
        } else { 
            echo 'Pick a category!'; 
        }  
    
    ?>
     
    Last edited: Jun 28, 2007
  2. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    get rid of the fucking table... that's hideous.

    Use fixed-width divs and float: left;
     
  3. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    parse your gets with htmlspecialchars otherwise you're open for SQL injection
     
  4. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    i didnt write this script, and i dont know php very well...

    heres what i got from someone in another thread..

    this is what it does http://www.prestigehomedesign.com/flooring.php?cat=1

    Code:
    <?php
    $query = "SELECT * FROM items WHERE";
        
        if (is_numeric($_GET['cat'])) {
            $cat = $_GET['cat'];
            $query .= " category ='$cat'";
            $var = TRUE;
        }
        
        if (is_numeric($_GET['gp1'])) {
            $gp1 = $_GET['gp1'];
            if (!$var) {
                $query .= " grp1 ='$gp1'";
            } else {
                $query .= " AND grp1 ='$gp1'";
            }
            $var = TRUE;
        }
        
        if (is_numeric($_GET['gp2'])) {
            $gp2 = $_GET['gp2'];
            if (!$var) {
                $query .= " grp2 ='$gp2'";
            } else {
                $query .= " AND grp2 ='$gp2'";
            }
            $var = TRUE;
        }
        
    if ($var) { 
            $result = mysql_query($query); 
            if (mysql_num_rows($result) > 0) { 
          echo "<table width=\"100%\">";
          echo "<tr style=\"font-weight: bold;\"><td>Picture</td><td>Color</td>\n";
          echo "<table width=\"100%\"><tr>";
                while ($fetch = mysql_fetch_array($result, MYSQL_ASSOC)) { 
                    echo "<td><a href=\"item.php?item={$fetch['id']}&cat={$fetch['category']}\" target=\"_blank\">".thumb(stripslashes($fetch['pic1']) ,stripslashes($fetch['brand']))." </a></td>";
                } 
                echo "</tr>\n";
            } else { 
                echo 'No items here.'; 
            } 
        } else { 
            echo 'Pick a category!'; 
        }  
    ?>
     
  5. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    STOP using tables.
     
  6. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    show me how not to :o
     
  7. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    put this in the <HEAD> section.
    Code:
    <style>
    span.gElement {
    	border: 0;
    	float: left;
            width: 300px;
    	height: 200px;
    	padding-left: 1px;
    	padding-right: 1px;
    	padding-top: 2px;
    	padding-bottom: 2px;
    	margin-left: 10px;
    	margin-bottom: 10px;
    	text-align: center;
    }
    </style>
    
    Code:
    <?php
    $query = "SELECT * FROM items WHERE";
        
        if (is_numeric($_GET['cat'])) {
            $cat = $_GET['cat'];
            $query .= " category ='$cat'";
            $var = TRUE;
        }
        
        if (is_numeric($_GET['gp1'])) {
            $gp1 = $_GET['gp1'];
            if (!$var) {
                $query .= " grp1 ='$gp1'";
            } else {
                $query .= " AND grp1 ='$gp1'";
            }
            $var = TRUE;
        }
        
        if (is_numeric($_GET['gp2'])) {
            $gp2 = $_GET['gp2'];
            if (!$var) {
                $query .= " grp2 ='$gp2'";
            } else {
                $query .= " AND grp2 ='$gp2'";
            }
            $var = TRUE;
        }
        
    if ($var) { 
            $result = mysql_query($query); 
            if (mysql_num_rows($result) > 0) { 
          
        while ($fetch = mysql_fetch_array($result, MYSQL_ASSOC)) { 
            
              echo "<span class="gElement"><a href=\"item.php?item={$fetch['id']}&cat={$fetch['category']}\" target=\"_blank\">".thumb(stripslashes($fetch['pic1']) ,stripslashes($fetch['brand']))."</a></span>";
          
           } 
               
            } else { 
                echo 'No items here.'; 
            } 
        } else { 
            echo 'Pick a category!'; 
        }  
    ?>
     
  8. MSTRMOO

    MSTRMOO Active Member

    Joined:
    Jul 19, 2005
    Messages:
    36,312
    Likes Received:
    0
    THANK YOU! :bowdown: that works great
     
  9. fishbulb

    fishbulb Active Member

    Joined:
    Oct 29, 2001
    Messages:
    6,848
    Likes Received:
    4
    Location:
    md
    Injection can be accomplished using a numeric string?
     

Share This Page