dazzclub Posted March 24, 2009 Share Posted March 24, 2009 Hi guys and girls.. I have a string in my database table that looks like this my name Is Darren I would like to retrieve string but remove the and have it displayed like this myNameIsDarren. Here is my code which simply retrieves it function trimPDFwhiteSpace() { global $dbc; $query = "SELECT SubCatName FROM subcat1"; $result = mysqli_query ($dbc, $query)or die(mysqli_error() . "<p>With query:<br>$query"); while ($row = mysqli_fetch_array($result)) { echo str_replace( "$row[subCatName]<br />"); } } would i need to go through the array removing the white space and then echoing it out? Any help or advice would be good, thank you Quote Link to comment Share on other sites More sharing options...
Yesideez Posted March 24, 2009 Share Posted March 24, 2009 echo str_replace(' ','',$row['SubCatName']).'<br />'; Quote Link to comment Share on other sites More sharing options...
Stephen68 Posted March 24, 2009 Share Posted March 24, 2009 Maybe you could use something like this <?php $content = $row[subCatName]; $content = str_replace(' ',"",$content); ?> Quote Link to comment Share on other sites More sharing options...
dazzclub Posted March 24, 2009 Author Share Posted March 24, 2009 Thank you for helping me Yesideez! Quote Link to comment Share on other sites More sharing options...
dazzclub Posted March 24, 2009 Author Share Posted March 24, 2009 and Stephen68, thank you Quote Link to comment Share on other sites More sharing options...
dazzclub Posted March 24, 2009 Author Share Posted March 24, 2009 Here is the finished code //gets all the pdf files related to that particular product function getPDFs() { if ((isset($_GET['medical_product'])) && (isset($_GET['subcat_id'])) && (is_numeric($_GET['medical_product'])) && (is_numeric($_GET['subcat_id']))) { //correctly accessed $medical_product=$_GET['medical_product']; $subcat_id=$_GET['subcat_id']; } else { $errors[] = 'You have accessed this page incorrectly.'; } global $dbc; $query="SELECT * FROM SubCat1 WHERE CategoryID = $medical_product AND SubCatID = $subcat_id"; $result = mysqli_query ($dbc, $query)or die(mysqli_error() . "<p>With query:<br>$query"); while ($row = mysqli_fetch_array($result)) { echo ' <tr> <td><a href="downloads/'.str_replace(' ','',$row['SubCatName']).'_IFU.pdf" target="_blank">Instructions For Use</a></td> </tr> <tr> <td><a href="downloads/'.str_replace(' ','',$row['SubCatName']).'_PI.pdf" target="_blank">Product Infrmation</a></td> </tr> <tr> <td><a href="downloads/'.str_replace(' ','',$row['SubCatName']).'_MSDS.pdf" target="_blank">MSDS</a></td> </tr> <tr> <td><a href="downloads/'.str_replace(' ','',$row['SubCatName']).'_CAC.pdf" target="_blank">Clinical Article Chart</a></td> </tr> <tr> <td><a href="downloads/'.str_replace(' ','',$row['SubCatName']).'_SS.pdf" target="_blank">Sell Sheet</a></td> </tr> '; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.