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 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2014
    Posts
    74
    Thanks
    11
    Thanked 0 Times in 0 Posts

    PHP only using 1 row, when there are 2

    I have a table with 2 rows in it, yet PHP is only acting on 1. Does anyone know why?

    Basically, it should be generating two items on a cart list page (the DIV's), but only the first is present.

    PHP Code:
    <?php
        $query 
    "SELECT * FROM cart WHERE cartholder = 1";
        
    $result mysql_query($query);
        while (
    $row mysql_fetch_assoc($result)) {
            
    $sizexs $row['sizexs'];
            
    $sizes $row['sizes'];
            
    $sizem $row['sizem'];
            
    $sizel $row['sizel'];
            
    $sizexl $row['sizexl'];
            
    $query "SELECT * FROM products WHERE number = ".$row['number']."";
            
    $result mysql_query($query);
            
    $row mysql_fetch_assoc($result);
            if (
    $row['gender'] == 'Mens') {$gender 'mens';} else {$gender 'womens';}
            if (
    $row['type'] == 'T-Shirt') {$type 't-shirts';}
            
    $number $row['number'];
            
    $brand $row['brand'];
            
    $name $row['name'];
            
    $price $row['price'];
            echo 
    '
                <DIV class="content">
                    <A href="/products/'
    .$gender.'/'.$type.'/product/?productnumber='.$number.'"><IMG alt="" src="/products/'.$gender.'/'.$type.'/'.$number.'/thumb.png"></A>
                    <BR>
                    '
    .$brand.'
                    <BR>
                    '
    .$name.'
                    <BR>
                    <BR>
                    $'
    .$price.'
                </DIV>
            '
    ;
        }
    ?>

  • #2
    New Coder
    Join Date
    Jan 2014
    Posts
    74
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Solved. Just redefined the second $row lookup.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Are you sure both rows have 1 in the cartholder field?
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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