I am trying to return an array:
PHP;
- $query = mysql_query("SELECT *
FROM product_list_sub
WHERE id='$prodID2'");
if (mysql_affected_rows() > 0)
{
$row = mysql_fetch_array($query) or die(mysql_error());
$stuff = array();
$name = $row['name'];
$price = $row['price'];
$query2 = mysql_query("SELECT *
FROM product_list_sub
WHERE id='$prodID2'");
if (mysql_affected_rows() > 0)
{
$row2 = mysql_fetch_array($query2) or die(mysql_error());
$id = $row2['id'];
}
$stuff[0]=$name;
$stuff[1]=$price;
$stuff[2]=$id;
echo json_encode($stuff);
} else {
echo "Product not found!";
}
- $.ajax({ url: 'process.php',
data: { productID2 : product},
type: 'post',
dataType: "json",
success: function(output) {
if(output){
alert(output[1]);
}
}
});
This does not have the pop up box with the value located in [1]. Is there something wrong with my code?