我正在尝试从多个表的多个列中获取值。代码如下所示:
<?php
$connect = mysql_connect("localhost","en","]9");
mysql_select_db("en");
$result = mysql_query("SELECT title, field_id_1 FROM exp_channel_titles, exp_channel_data") or die(mysql_error());
// check for empty result
if (mysql_num_rows($result) > 0) {
// looping through all results
// products node
$response["video_path"] = array();
while ($row = mysql_fetch_array($result)) {
// temp user array
$s1 = explode('"',$row['field_id_1']);
$path = array();
$path["field_id_1"] = $s1[5];
$path["title"] = $row["title"];
array_push($response["video_path"], $path);
}
// success
$response["success"] = 1;
// echoing JSON response
echo json_encode($response);
} else {
// no products found
$response["success"] = 0;
$response["message"] = "No products found";
// echo no users JSON
echo json_encode($response);
}
?>
结果,这些值出现了两次,而不是只出现一次。我检查了这两个表,但这两个表确实包含同名的列。