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
https://forums.phpfreaks.com/topic/109667-substr-returning-nothing/
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.)

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.