http://i325.photobucket.com/albums/k392/sarjan123/name.jpg

hi all,
for the picture above,i am currently writing a code to check if the seller_name is match with current login user name,it will show the item name in a page,

i have following code now

 <?php
$check =$_SESSION['username'];
                        $query = "SELECT id, seller_name ";
            $query .= "FROM items ";
            $query .= "WHERE seller_name = '{$check}' ";
            $query .= "LIMIT 1";
            $result_set = mysql_query($query);
            confirm_query($result_set);

            if (mysql_num_rows($result_set) == 1)
                        {
                            $result = mysql_query("SELECT * FROM items WHERE seller_name='$check'");

            while($row = mysql_fetch_array($result))
            {
            $name = $row['item_name'];


             } }
                         else
                         {
                            $message = "you not selling anything currently";
                         }
                        ?>

//i using following code to print the item name
<?php echo $name; ?>

let say my username is kokfui,
this code actually is echoing the most bottom item name only,
so now i wondering how can i correct the code so that is will echo all item name which the seller name is match with the kokfui.
is their any looping method can use or any better ways?
can anyone help me?thanks

echo it inside the while loop. Now that it is outside, the $name variable will hold the last name.

Hope you understood and hope this was of help.

set name as a array - that way each loop will store its entry in name array

foreach($var1 as $ var2){echo $var2;}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.