Jump to content

Archived

This topic is now archived and is closed to further replies.

Tandem

mysql_fetch_array

Recommended Posts

Is there anyway to specifiy a certain row number for mysql_fetch_array? Or do i need a different function all together?

Share this post


Link to post
Share on other sites
I was faced with this dilemna a long time ago... put in an 'id' field in MySQL (assuming you meant you want to only pull a row from MySQL DB)

Call the query
[code]
$query = mysql_query( "SELECT * FROM `table_name` WHERE id = 'some id'" );
[/code]

Let us know if that helps

Share this post


Link to post
Share on other sites
Thanks for the reply.

Thats not what i meant, i probably should have gone into more detail, sorry about that :P

I'm using a for loop to pull multiple rows from a table and display them in order, via Select * from....etc. But now i need to start the process from a certain row. Is there any way to do that?

Share this post


Link to post
Share on other sites
Ahhhhhhh, yes...  place this after your order by statement in the query...

[code]
LIMIT OFFSET offest_row
[/code]

http://dev.mysql.com/doc/refman/5.0/en/select.html

Share this post


Link to post
Share on other sites
Sorry, since you are limiting to 1 row, go with what extrovertive said, but be sure to check out MySQL's page for help on that kinda stuff, they are very in depth with it.

Share this post


Link to post
Share on other sites
I think you are both misunderstanding me. I'm gonna go into way more depth so you can get more of an uderstanding of where i'm coming from. Sorry for not just doing that in the first place.

Ok. A few months ago i made a message board/forum. I'm now currently trying to make it so that the number of topics displayed on a single page is limited.

To display the topics i use (This is very simplified from the real thing):

[code]
$get_topic_details = mysql_query("SELECT * FROM FORUM");
for ($i = 0 ; $i < $number_of_topics ; $i++) {
$topic_details = mysql_fetch_array($get_topic_details);
echo "$topic_details[1]";
}[/code]

This cycles through the rows., and echo's $topic_details[1] which would be the title or something. But now i want to create different pages showing the topics that have fallen below the top 30, showing 30 topics per page. I want to be able to start the mysql_fetch_array at row 30, or or any other number i may need to start it at. How would i go about this. Please say if you need more detail.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.