Hi there,

Can anyone help?

Why is the following code displaying "P1P2P3..." etc, instead of "P1 , P2, P3 ,.." etc. ?

Thanks

Paul

<!--Conect to database-->
    <?php include "connects/patientconn.php"; ?>

    <?php

    $query = "SELECT `Patient I.D.` FROM `patient`";

    $result = mysql_query($query);

    while($patient = mysql_fetch_assoc($result))
    {
    $pt = implode(" , ", $patient);
    echo $pt;
    }
    ?>

I'm guessing implode doesn't do anything since $patient is not an array.

Change line 13 to:

echo "$pt, ";

mysql_fetch_assoc returns an array (with only one element in above case) and implode returns a string (P1, P2, P3 etc on each iterration).

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.