Jump to content

Archived

This topic is now archived and is closed to further replies.

dazzclub

[SOLVED] remove   from my string

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
echo str_replace(' ','',$row['SubCatName']).'<br />';

Share this post


Link to post
Share on other sites

Maybe you could use something like this

 

<?php
$content = $row[subCatName];
$content = str_replace(' ',"",$content);

?>

Share this post


Link to post
Share on other sites

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>
  
';
}
}

Share this post


Link to post
Share on other sites

×
×
  • 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.