如何将两个sql行添加到php数组中

I want to add two values from two rows to an array. One is a path and the other is a tag. I'm then encoding the array. So I can display the image and then I'm going to using the tags to order the new javascript array dynamically. I would like "echo $data;" to say something like [{path, tag}, {path, tag}]

<?php

include("mysqlconnect.php");

$select_query = "SELECT `ImagesPath`,`Tag` FROM `offerstbl` ORDER by `ImagesId` DESC";
$sql = mysql_query($select_query) or die(mysql_error());   
$data = array();
while($rows = mysql_fetch_array($sql,MYSQL_BOTH)){
$data[] = $rows['ImagesPath']['Tag'];
}
echo json_encode($data);
echo $data[0];
?>

I'm going to guess that "h" is the first character in the ImagePath string that is being returned from $rows['ImagesPath']['Tag']. I'm guessing that $rows['ImagePath'] is a string and you've asked for the ['Tag'] key within that string. Which isn't found for obvious reasons and the first character is then returned.

Since ImagePath and Tag are separate columns in the table you can't access both simultaneously. If you want the output to be [{path, tag}, {path, tag}] then you will need to change:

$data[] = $rows['ImagesPath']['Tag'];

to

$data[] = array($rows['ImagesPath'], $rows['Tag']);