Jump to content

Substr returning nothing


fat creative

Recommended Posts

I'm trying to limit the number of characters returned and have the following code:

 

 

$query = "SELECT * FROM GFF WHERE featured_site = 'yes'";

$result = mysql_query($query)

    or die ("Couldnt execute query");

 

$prop = substr($prop_desc, 0, 150);

 

  echo "<table cellspacing=\"15\">\n";

  while($row = mysql_fetch_assoc($result))

  {

      extract($row);

      echo "<tr><td valign=\"top\">";

      echo "<img src=\"$thumb_image\" width=\"125\" height=\"94\" align=\"middle\" ></td>";

      echo "<td valign=\"top\"><a href=\"showdetails.php?id_number=$id_number\"><b>$prop_title</b></a><br />";

      echo "$prop<br />";

      echo "<a href=\"showdetails.php?id_number=$id_number\"><div align=\"right\"><b>View Details</b></div></a>";

      echo "</td></tr>\n";

  }

 

echo "</table>\n";

 

It looks like such a simple thing, but as a newbie, I'm obviously missing something since it's not working!  My page is at www.FatCreative.com/GFF. 

 

If I just say echo $prop_desc, then it works fine, but doesn't look nice. When I put in $prop = substr($prop_desc, 0, 150);  and  echo "$prop<br />"; then it returns nothing.

 

Any thoughts anyone?  I think this is the last thing I need to finish this project.  Thank you so much in advance for ANY suggestions / advice!

 

Link to comment
Share on other sites

I think darkwater is right - your code should look like:

 

 while($row = mysql_fetch_assoc($result))
   {
      extract($row);
      $prop = substr($prop_desc, 0, 150); 

 

with the rest remaining as it is already.

 

Link to comment
Share on other sites

Noone's crazy here, just much much smarter than me.  I didn't realize it mattered if the statement was in the while loop.  I have SO MUCH to learn. Thank you, Darkwater, Bther - you were both spot on!

 

It only matters because that's where you set the $row variable (which you then extract), giving you $post_desc. =)

Glad I could help, lol.

 

(Oh, btw, is it really hot in Atlanta?  I'm going there for like, a 4 day business conference...and I don't want to die.)

Link to comment
Share on other sites

You certainly did! The things that seem like they should be so easy frustrate me the most. I unfortunately just missed signing up for a class at the local college when this project came up. I am definitely signing up the next semester. And I remember you said you had a conference coming up here in GA.  I hope that link for the list of things to do in Atlanta was helpful.  YES it is VERY HOT. Well humid.  You will pretty much walk outside and be SOAKED in a matter of minutes. Be warned.  :-) And thanks again...

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.