Hi all I am request the following data from the database (image_id and description).
I need to put each of them in a separate arrays and then echo out contents of both arrays

I have tried array_push and implode without success. Any assistance would we appreciated.

Thanks in advance
D

    mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
    mysql_select_db("$db_name")or die("cannot select db");

    $sql ="  SELECT
      web_customised_partners.image_id,
      web_customised_partners_id,
      description,
                  web_images.image_id,
                  web_images.image_filename
        FROM
      web_customised_partners
         LEFT JOIN
      web_images ON web_images.image_id = web_customised_partners.image_id ";
      $result=mysql_query($sql);
        ?>
     <div class="content">
        <div id="about_customised_partner">
            <div class="inner">
                <?php
                  while($row = mysql_fetch_array($result))
                     {

                         $image_value = array();
                         array_push ($image_value,$row['image_id']);
                         print_r($image_value);

                         $description_value = array();
                         array_push ($description_value,$row['description']);
                         print_r($description_value);
                      }
                ?>
            </div>
         </div>
      </div>

Move these:

$image_value = array();
$description_value = array();

outside the while statement, otherwise the array resets after each loop. Also you can avoid the use of array_push() by writing:

while($row = mysql_fetch_array($result))
{
    $image_value[] = $row['image_id'];
    $description_value[] = $row['description'];
}
Member Avatar for iamthwee

Details of the ACTUAL errors would be useful.

Thanks Cereal for your answer

Point also noted iamthee
D

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.