从SQL数据库中检索列表并为AS3中的每一行创建链接

时间:2016-01-11 23:15:29

标签: php mysql actionscript-3 flash air

我正在尝试使用以下条件执行AIR应用程序:

我有一个SQL数据库。在我的表格中有一个“类别”列(包含不同类别(计算机,书籍......等))。

enter image description here

在我的AS3中,我设法在用户选择类别时检索“theDescription”。 使用URLMethod和php文件。

    // create SQL
     $sql = "SELECT * FROM annonces where categorie = '$categorie'";
     $sql_result = mysql_query($sql, $connection) or die ("Couldn't execute query.");
     $num = mysql_numrows($sql_result);
    $phptheDescription = "";
    $counter = 0;
    while ($row = mysql_fetch_array($sql_result)) {
     $theDescription = $row["theDescription"];
    $phptheDescription = $theDescription;
    }
echo  "phptheDescription=" . $theDescription;

所以我的AS3代码正在从php中检索$ phptheDescription并将其显​​示在output_txt中。

问题:在我的output_txt中,只显示一个“theDescription”。但我在类别“Informatique”中有两个项目(我可以在同一类别中拥有100个项目)。

如何显示属于同一类别的所有“theDescription”?

例如:如果我选择“Informatique”,它应显示“Une Surface Pro 3”和“Un IMAC”。 但它只显示最后一项“Un IMAC”。

然后,是否可以为显示的每个项目创建“链接”?

修改

解释我的问题的视频:

https://vid.me/DS2r

http://sendvid.com/6iesrygk

1 个答案:

答案 0 :(得分:2)

你已经有了行,但是你没有回应这些描述,你可以编辑你的代码:

while ($row = mysql_fetch_array($sql_result)) {
 $theDescription = $row["theDescription"];
 //$phptheDescription = $theDescription;
 echo $theDescription;
}

或连接像这样的所有字符串

$phptheDescription='';
while ($row = mysql_fetch_array($sql_result)) {
     $theDescription = $row["theDescription"];
     $phptheDescription = $phptheDescription.' , '.$theDescription;
    }
 echo $phptheDescription;