Jump to content

[SOLVED] Replace ' / \ with nothing from a query


grahamb314

Recommended Posts

Hi all,

 

The folowing code takes the row "Shows" from a database table and puts it into an option drop down to select from.

I want to be able to remove apostrophies: '  and  slashes / and \ from the drop down box results, but leave them intact on the database.

 

Any ideas?

I thought about making an array of ' / \ and then saying if each row form the query result  contains one or more of these, then remove them from the row list but i'm not advanced enough!

 

Thanks!

 

 

<?php

require_once 'mysql_connect.php';  

$DJshows = mysqli_query($mysqli, "SELECT * FROM schedule");

str_replace("'", "", "$DJshows");

while ($show = mysqli_fetch_assoc($DJshows)) {

 echo "<option value=\"{$show['Show']}\">{$show['Show']}</option>";
}
//str_replace("'", "", "$show['Show']");
?>

Error in the above code:

New code:

<?php

//connect to DB with user and pass
require_once 'mysql_connect.php';  
//query
$DJshows = mysqli_query($mysqli, "SELECT * FROM schedule");

while ($show = mysqli_fetch_assoc($DJshows)) {

    echo "<option value=\"{$show['Show']}\">{$show['Show']}</option>";
}

?>

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.