【问题标题】:loading images and data from mysql into Flash using PHP?使用 PHP 将图像和数据从 mysql 加载到 Flash 中?
【发布时间】:2013-03-18 20:10:12
【问题描述】:

我有一个 mysql 数据库,其中保存了产品名称、价格和详细信息。这是使用 PHP 完成的。而且效果很好。

我只需要使用 AS3 将产品的图像及其详细信息加载到 Flash 中。

这是我的 PHP 代码:

<?php 
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php 
// Run a select query to get my letest 6 items
// Connect to the MySQL database  
include "../config/connect_to_mysql.php"; 
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
    while($row = mysql_fetch_array($sql)){ 
             $id = $row["id"];
             $product_name = $row["product_name"];
             $price = $row["price"];
             $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
             $dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6">
        <tr>
          <td width="17%" valign="top"><a href="../product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="../inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /></a></td>
          <td width="83%" valign="top">' . $product_name . '<br />
            $' . $price . '<br />
            <a href="../product.php?id=' . $id . '">View Product Details</a></td>
        </tr>
      </table>';
    }
} else {
    $dynamicList = "We have no products listed in our store yet";
}
mysql_close();
?>
<?php echo $dynamicList; ?>

任何帮助将不胜感激。

谢谢

【问题讨论】:

  • 您可以使用 PHP 创建 XML 或 JSON 结构并从 flash/flex 应用程序调用服务。在这里您可以找到生成 XML 的代码:cristalab.com/tutoriales/…
  • 在这里您可以找到使用 Flash 读取 XML 的示例:republicofcode.com/tutorials/flash/as3xml
  • 谢谢,但是你给我的第一个链接不是英文的!!我不明白
  • 我觉得这个答案可能对你有用=)

标签: php mysql actionscript-3 flash


【解决方案1】:

1.- 使用PHP和SQL生成XML文件

->http://code.activestate.com/recipes/576499-converting-mysql-queries-to-xml/

2.- 使用 Flash/Flex 显示比您从 XML 获得的数据

->http://www.republicofcode.com/tutorials/flash/as3xml/

3.- 发挥你的想象力,创造一些伟大的东西:

->http://www.republicofcode.com/tutorials/flash/as3slideshow/

【讨论】:

    猜你喜欢
    • 2011-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-07
    • 2012-10-09
    • 2020-03-16
    • 2016-10-13
    • 1970-01-01
    相关资源
    最近更新 更多