0

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

Edited by mike_2000_17: Fixed formatting

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by anilashanbhag
0

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.

0

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

foreach($var1 as $ var2){echo $var2;}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.