Re: Using strlen and substr to Shorten DB Results

From: Date: Sun, 26 Jan 2003 22:24:11 +0000
Subject: Re: Using strlen and substr to Shorten DB Results
Groups: php.db 
Request: Send a blank email to php-db+get-25152@lists.php.net to get a copy of this message
$sub_cat is an array so you can omit the pipe when you get to count ($sub_cat); with an if block. there my be an easier way though. hth Jeff "Jami" <jami@jamisnic To: <php-db@lists.php.net> he.com> cc: Subject: [PHP-DB] Using strlen and substr to Shorten DB Results 01/26/2003 05:07 PM Please respond to jami I have a script that I am working on that pulls info from a database: <-- Code --> $getscname = mysql_query("SELECT * FROM subcat WHERE subcatid = '$subcatid'") or die ("Couldn't get the info.<br>".mysql_error()); while($sub_cat = mysql_fetch_array($getscname)){ $subcat_id = $sub_cat['subcatid']; $subcat_name = $sub_cat['subcatname']; echo '<a href="subcat.php?catid='.$catid.'&sc='.$subcat_id.'">'.$subcat_name.'</a >&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;'; } <-- Code --> At the end of each link, a pipe is printed. I want to take the pipe off of the last result, so that the page will prit out: SubCat1 | SubCat2 | SubCat3 I've tried using strlen & substr to do this, but it cuts the pipe off of all the results, not the last one. Any suggestions? TIA. -------- Jami jami@jamisniche.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.db (#25152) next »