Jump to content


Photo

mysql_fetch_array


  • Please log in to reply
8 replies to this topic

#1 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 04 September 2006 - 03:48 AM

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

#2 marker5a

marker5a
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 04 September 2006 - 03:49 AM

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
$query = mysql_query( "SELECT * FROM `table_name` WHERE id = 'some id'" );

Let us know if that helps

#3 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 04 September 2006 - 03:52 AM

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?

#4 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 04 September 2006 - 03:54 AM

Ya, look into LIMIT

SELECT * FROM table
LIMIT (the row, 1)

#5 marker5a

marker5a
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 04 September 2006 - 03:55 AM

Ahhhhhhh, yes...  place this after your order by statement in the query...

LIMIT OFFSET offest_row

http://dev.mysql.com.../en/select.html

#6 marker5a

marker5a
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 04 September 2006 - 04:00 AM

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.

#7 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 04 September 2006 - 04:11 AM

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

$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]";
}

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.

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 04 September 2006 - 04:14 AM

it's called pagination.  do a search on that keyword. lots of posts and tutorials here about it.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#9 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 04 September 2006 - 04:21 AM

Ya, paginiation deals with manipulation of LIMIT in mysql.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users