Jump to content

[SOLVED] Endless while loop


shatteredcode

Recommended Posts

Alright, I accept that I cannot solve this. I'm doing something in this code to make a REALLY big loop. It crashes my browser. Could you tell me my error? Thanks in advance.

 

	
function get_posts($table_name,$num_of_posts)
{
	$query = "SELECT * from $table_name LIMIT $num_of_posts";
	$result = mysql_query($query);
	if (!$result)
		{
			die(mysql_error());
		}
	echo ('<div id = "blog">');		
	while ($result <= $num_of_posts)
		{
			$row = mysql_fetch_row($result);


			echo ('<div id = "blog_title">');
			echo ($row[1] . "<br />");

			echo ('<div id = "blog_date">');
			echo ($row[2] . "<br />");

			echo ('<div id = "blog_tags">');
			echo ($row[3] . "<br />");

			echo ('<div id = "blog_post">');
			echo ($row[4] . "<br />");	
		}
	echo ("</div>"); 
}

 

I'm sure it's a stupid mistake. Thanks in advance.

-Rick

 

Link to comment
Share on other sites

TRY

	
function get_posts($table_name,$num_of_posts)
{
	$query = "SELECT * from $table_name LIMIT $num_of_posts";
	$result = mysql_query($query);
	if (!$result)
		{
			die(mysql_error());
		}
	echo ('<div id = "blog">');		
	while ($row = mysql_fetch_row($result))
		{
			//$row = mysql_fetch_row($result);


			echo ('<div id = "blog_title">');
			echo ($row[1] . "<br />");

			echo ('<div id = "blog_date">');
			echo ($row[2] . "<br />");

			echo ('<div id = "blog_tags">');
			echo ($row[3] . "<br />");

			echo ('<div id = "blog_post">');
			echo ($row[4] . "<br />");	
		}
	echo ("</div>"); 
}

 

Link to comment
Share on other sites

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.