Jump to content

Recommended Posts

for some reason when i shorten my code form

	<?php $getreplies = "Select * from forumtutorial_posts where parentid='$forumpostid' ORDER BY showtime DESC LIMIT 0, 10"; //getting replies
			$getreplies2 = mysql_query($getreplies) or die(mysql_error() .
							"Could not get replies");
			while ($getreplies3 = mysql_fetch_array($getreplies2))?>

 

to

 

<?php $getreplies3 = mysql_fetch_assoc(mysql_query("Select * from forumtutorial_posts where parentid='$forumpostid' ORDER BY showtime DESC LIMIT 0, 10"));?>

 

it only shows one result rather then 10.... how comes?

Link to comment
https://forums.phpfreaks.com/topic/132118-solved-short-coding-not-working-right/
Share on other sites

You need the loop to fetch all of the entries. The query only gets a pointer to the retrieved set. The fetch actually gets the data, one row at a time.

 

BTW, leave the 3 lines -- it's much easier to debug if anything goes wrong.

 

Ken

 

BTW, leave the 3 lines -- it's much easier to debug if anything goes wrong.

 

Ken

 

Exactly.  Do not sacrifice your code readability for filesize.  This is not the 1980's when every byte counted.  Shortening your code like that is like the difference between you trying to decide whether to drive down to storeA or to storeB that's next door.  You won't even factor into the equation the distance, because in your eyes, it's the same, because it's like, next door. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.