0

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 Answers 3

7
$rss = array();
while (...) {
    $rss[] = $row['xmlurl'];
}
Sign up to request clarification or add additional context in comments.

Comments

3

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);

1 Comment

Thank you for your responses. They are very much appreciated!
2
// 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'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.