fat creative Posted June 11, 2008 Share Posted June 11, 2008 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 More sharing options...
DarkWater Posted June 11, 2008 Share Posted June 11, 2008 Call me crazy, but I don't see where you set $prop_desc. And if it's supposed to come from that extract() call, then the $prop = substr() line needs to be in the while loop. =P Link to comment https://forums.phpfreaks.com/topic/109667-substr-returning-nothing/#findComment-562678 Share on other sites More sharing options...
btherl Posted June 11, 2008 Share Posted June 11, 2008 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 https://forums.phpfreaks.com/topic/109667-substr-returning-nothing/#findComment-562686 Share on other sites More sharing options...
fat creative Posted June 11, 2008 Author Share Posted June 11, 2008 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! Link to comment https://forums.phpfreaks.com/topic/109667-substr-returning-nothing/#findComment-562718 Share on other sites More sharing options...
DarkWater Posted June 11, 2008 Share Posted June 11, 2008 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 https://forums.phpfreaks.com/topic/109667-substr-returning-nothing/#findComment-562721 Share on other sites More sharing options...
fat creative Posted June 11, 2008 Author Share Posted June 11, 2008 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 https://forums.phpfreaks.com/topic/109667-substr-returning-nothing/#findComment-562728 Share on other sites More sharing options...
DarkWater Posted June 11, 2008 Share Posted June 11, 2008 D'oh. >_< I thought it was bad in New York today....100 degrees (air temperature) and it felt like 108 some times during the day with humidity...I was dying in school. Greatttt....At least I get to stay at a nice hotel. =P Link to comment https://forums.phpfreaks.com/topic/109667-substr-returning-nothing/#findComment-562730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.