Jump to content

Recommended Posts

I'm new to php so forgive me for asking noobie questions as I don't have my books with me..

 

How do I modify my current code to allow me to only retrieve a brief part of the content, say this first 600 words or so?

 

	
$get_information = mysql_query("SELECT * FROM information WHERE category = '1'") or die(mysql_error());
while($information = @mysql_fetch_assoc($get_information))
{
	$information_title = $information['title'];
	$information_content = $information['content'];
	echo "<b>" . $information_title . "</b><br />" . $information_content . "<hr>" ;
}

 

Also, how do I put information retrieved from the database into a form?

 

Thanks for your help, greatly appreciated..

maybe in the SQL you use LIMIT to limit the record to 600..or else

 

you may use for loop...for $i=0; $i<600; $i++

 

here you are using while loop...which will retrieve ALL data that match ur query at once.

 

regards,

 

chai

<?php

$get_information = mysql_query("SELECT * FROM information WHERE category = '1'") or die(mysql_error());
while($information = @mysql_fetch_assoc($get_information))
{
	$information_title = $information['title'];
	$information_content = substr($information['content'], 0, 500) ;
	echo "<b>" . $information_title . "</b><br />" . $information_content . "<hr>" ;
}

?>

 

 

will do the 500 characters

 

 

<?php

$get_information = mysql_query("SELECT * FROM information WHERE category = '1'") or die(mysql_error());
$information = @mysql_fetch_assoc($get_information)

$information_title = $information['title'];
$information_content = explode(' ',$information['content']) ;
$n = 0;   
echo ($information_title .'<br><br />');
while($n <= 599)
   {
     echo $information_content['$n']; 
     $n++;		
   }
echo '<hr>';
?>

 

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.