php
  • mysql
  • actionscript-3
  • flash
  • air
  • 2016-01-11 43 views 0 likes 
    0

    每一行,我试图做一个AIR应用程序与这些条件链接:从SQL数据库检索列表,并创建在AS3

    我有一个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”。但是我在“信息”类别中有两个项目(我可以在同一类别中有100个项目)。

    我该如何显示所有属于同一类别的“theDescription”?例如:如果我选择“Informatique”,它应该显示“Une Surface Pro 3”和“Un IMAC”。 但它只显示最后一项“Un IMAC”。

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


    编辑

    影片解释我的问题:

    https://vid.me/DS2r

    http://sendvid.com/6iesrygk

    回答

    2

    你已经为行,但你没有回音的说明,您可以编辑您的代码是:

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

    或CONCAT这样

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

    所有字符串为了使超链接只是包装的$ theDescription在锚标签回声后。 –

    +0

    这里是我在视频中的问题(更容易理解):https://vid.me/DS2r – user3094896

    +0

    而链接的问题:http://sendvid.com/6iesrygk(它开始的方式相同,但与视频不同前一篇文章) – user3094896

    相关问题