Quantcast
Channel: WordPress.com Forums » Recent Topics
Viewing all articles
Browse latest Browse all 74536

celine22b on "php loop issue"

$
0
0

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>

Viewing all articles
Browse latest Browse all 74536

Trending Articles