...

View Full Version : basic sql help please!!



LJackson
04-01-2009, 02:45 PM
Hi All,

i need some basic help please,

i am having trouble getting a list of info from a specific row in my database, i have checked the number of rows which returns the correct number but when i print out my results i am getting the first record print out 47 times instead of each of the 47 records printing out once.

where am i going wrong with this?


$sql = "SELECT *
FROM rss_feeds
WHERE description = 'top'";
$query = mysql_query($sql);
$row = mysql_fetch_array($query);
$rows = mysql_num_rows($query);

for ($i = 0; $i < $rows; $i++) {
$feedURL[$i] = $row['s_FeedURL'];
print $feedURL[$i];
print "<br />";
}

cheers

guelphdad
04-01-2009, 02:53 PM
your question is likely not to do with sql but your php code. run your query directly in mysql client and see if it gives you correct rows. if it does you've just verified the problem is your output code.

take a look in the php manual to make sure you are looping correctly.

LJackson
04-01-2009, 03:05 PM
ok thanks mate,

just checked the sql and its displaying the correct records,

i will check the php manual to see if that helps :)

cheers

Hayyel
04-02-2009, 11:54 AM
How about using while instead of for?


$sql = "SELECT *
FROM rss_feeds
WHERE description = 'top'";
$query = mysql_query($sql);
$row = mysql_fetch_array($query);
$rows = mysql_num_rows($query);

while ($i = 0; $i < $rows; $i++) {
$feedURL[$i] = $row['s_FeedURL'];
print $feedURL[$i];
print "<br />";
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum