mike12255 Posted April 1, 2009 Share Posted April 1, 2009 I got a peice of code (result ccan be seen at http://schoolworkanswers.com/kaon/products.php?a=Sofas) and its suposed to subtract from a string till its 20 chars long then add ... at the end, so i tried using substr to 3 to test that and thats not working either idk what to do any idaes?? $cols = 5; // number of columns here $count = 1; $rows = 0; while ($row = mysql_fetch_array($result)){ extract($row); if ($count % $cols == 0) { echo "</tr>"; // or close a tr and open a new one, etc.. echo "<tr>"; $count++; $rows++; } $img = str_replace("../","",$th_path); $pdname = $pd_name; if(strlen($pd_name > 3)){ $pdname = substr($pdname,0,20); $pdname = $pdname . "..."; } echo "<td aling = center><img src=$img alt=''><br>$pdname</td></td>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/152012-substradding-string-dosnt-work/ Share on other sites More sharing options...
Andy-H Posted April 1, 2009 Share Posted April 1, 2009 <?php $cols = 5; // number of columns here $count = 1; $rows = 0; while ($row = mysql_fetch_array($result)){ extract($row); if ($count % $cols == 0) { echo "</tr>"; // or close a tr and open a new one, etc.. echo "<tr>"; $count++; $rows++; } $img = str_replace("../","",$th_path); if(strlen($pdname > 23)){ $pdname = substr($pdname,0,20); $pdname = $pdname . "..."; } echo "<td aling = center><img src=$img alt=''><br>$pdname</td></td>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/152012-substradding-string-dosnt-work/#findComment-798317 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.