Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-01-2009, 02:45 PM   PM User | #1
LJackson
Senior Coder

 
Join Date: Jun 2008
Location: Cornwall
Posts: 1,973
Thanks: 289
Thanked 12 Times in 12 Posts
LJackson is on a distinguished road
Exclamation basic sql help please!!

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?

PHP Code:
$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
LJackson is offline   Reply With Quote
Old 04-01-2009, 02:53 PM   PM User | #2
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
Old 04-01-2009, 03:05 PM   PM User | #3
LJackson
Senior Coder

 
Join Date: Jun 2008
Location: Cornwall
Posts: 1,973
Thanks: 289
Thanked 12 Times in 12 Posts
LJackson is on a distinguished road
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
LJackson is offline   Reply With Quote
Old 04-02-2009, 11:54 AM   PM User | #4
Hayyel
New Coder

 
Join Date: Jan 2009
Posts: 91
Thanks: 17
Thanked 1 Time in 1 Post
Hayyel is an unknown quantity at this point
How about using while instead of for?

PHP Code:
$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 />"

Hayyel is offline   Reply With Quote
Users who have thanked Hayyel for this post:
LJackson (04-06-2009)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:47 AM.


Advertisement
Log in to turn off these ads.