php loop issue

  • Unknown's avatar

    Hi,

    I’m new to all this so any help is appreciated.

    I’m trying to return the contents of a table but my code captures everything but the first row.

    Below is a simple version of the code which

    produces 23456789 when it should produce 123456789.

    Thanks for your help.

    <?php
    
    require_once("mysqli_connect.php");
    
        $check_query = 'SELECT * FROM products';
        $result = mysql_query($check_query, $connection) or die(mysql_error());
        $row = mysql_fetch_assoc($result)
    ?>
    <html>
        <head>
            <title>Title</title>
        </head>
        <body>
            <?php
            while ($qdata = mysql_fetch_array($result, MYSQL_ASSOC)) {
                foreach($qdata as $key => $value) {
                    if($key =='item'){
                       echo $value.',<br />';
                    }
                }
            }
            ?>
        </body>
    </html>
  • Unknown's avatar

    You did not specify a blog address or reason for posting when you created this topic.

    This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.

    If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.

    If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.

    This is an automated message.

  • The topic ‘php loop issue’ is closed to new replies.