gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 07:25:24 25 4
gpt4 key购买 nike

我正在尝试制作具有以下条件的 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

最佳答案

您已经获取了行,但没有回显描述,您可以将代码编辑为:

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;

关于php - 从 SQL 数据库检索列表并为 AS3 中的每一行创建链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34732909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com