如何使用app inventor + PHP从MySQL中检索多个值?

To store in MySQL I had to use the 'explode' PHP function, so each value would go to each attribute, and it works fine, however when I try to retrieve a row with all the values in it, it just displays the 'tag' (let's say forename) and 'value' (let's say surname), but all the other attributes is repeated with the surname. Example:

Forename: John
Surname:  Walker
Age:      Walker
Phone:    Walker

Where the last 2 'Walker' would be another attribute value such as Age and Phone.

Thanks in advance!!!

Here is part of my Retrieval PHP code:

mysql_query($query);
$forename=$_POST['tag'];
$forename = trim($forename);
$query =  sprintf("select `forename`, `surname`, `age`, `phone` from `tinywebdb` where `forename` = '%s' limit 1", mysql_real_escape_string($forename));
if($link){ $result=mysql_query($query) ;}     
if($entry = mysql_fetch_assoc($result)) 
{
    $forename = $entry["forename"];
    $surname = $entry["surname"];
    $age = $entry["age"];
    $phone = $entry["phone"];
} 
else 
{
    fwrite($fh,"No Entry found in MYSQL for name : ". mysql_real_escape_string($forename));
}
echo json_encode(array("value", $forename, $surname, $age, $phone));

Have you tried mysql_fetch_array instead of mysql_fetch_assoc?

Make an echo before you put it in an Array maybe you can figure out more.

Check what happens when $link = false. You still proceed with an mysql_fetch_assoc($result) even when $link is false and there is no $result.

last but not least: do not use the same variable as input and as output. You will never know if the $forename (John) is filled before or after the query.