English 中文(简体)
要排列的 PHP - 排除麻烦
原标题:PHP to Array - Troubleshooting
  • 时间:2012-05-25 01:31:22
  •  标签:
  • php
  • arrays

我知道我在这里犯了新手的错误,我需要做一个变数才能向前传递,尽管我不确定如何接近这个变数,而上网搜索图纸也无济于事。 如果有人能指引我走正确的方向,我会非常感激。

我希望将结果反馈到一个数组中。 也就是说, 将 xmlurl 列字段从 xml 表格显示在 $rss 数组中。 我希望这有道理 。

// 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 
);
最佳回答

尝试此 :

$rss = array();

$result = mysql_query("SELECT * FROM xml");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $rss[] = $row["xmlurl"];
}
mysql_free_result($result);
问题回答
$rss = array();
while (...) {
    $rss[] = $row[ xmlurl ];
}
// Get URLs from Database
$result = mysql_query("SELECT * FROM xml");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $rss[] = $row["xmlurl"]);
}
mysql_free_result($result);

print_r($rss); // Outputs the $rss array, listing all of the xmlurls 




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签