Jump to content

Substr/Adding string dosnt work


mike12255

Recommended Posts

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

<?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>";
  }
  }

?>

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.