douzi2333 2012-05-25 01:31
浏览 21
已采纳

PHP到阵列 - 故障排除

I know I am making rookie errors here, and that I need to make a variable to pass forward - though I am not sure how to approach this one, and searching online tutes is not helping. If someone can steer me in the right direction I would be really grateful.

I would like to have the results echo into an array. That is; have 'xmlurl' row field from the 'xml' table display in the $rss array. I hope that makes sense.

// Get URLs from Database
$result = mysql_query("SELECT * FROM xml");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("'%s',", $row["xmlurl"]);
}
mysql_free_result($result);

// Take the URLs (xmlurl) and place them in an array
$rss = array(
'http://www.xmlurl.com.au',
'http://www.xmlurl.com.au'
);
  • 写回答

3条回答 默认 最新

  • dongyinting3179 2012-05-25 01:33
    关注

    Try this:

    $rss = array();
    
    $result = mysql_query("SELECT * FROM xml");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $rss[] = $row["xmlurl"];
    }
    mysql_free_result($result);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助