Jump to content

[SOLVED] How do I get php to put %20 when there is a space?


Dustin013

Recommended Posts

I am querying a database for a list of directories. The query is simply returning the name of the directory that is stored in the mysql database. For example the query will search for anything starting with the letter B.

 

This would result in returning Brandon Folder1.

 

To see the contents of that folder I am passing information through the URL, script2.php?item=Brandon Folder1. What I need for the script to do is if there is a space in the directory of the folder like above, I need it do, script2.php?item=Brandon%20Folder1... any suggestions?

 

Here is my query

 

$query  = "SELECT * FROM `testdb` WHERE `foldername` LIKE CONVERT( _utf8 '".$item."%' USING latin1 ) COLLATE latin1_swedish_ci";
$result = @ mysql_query ($query)
    or die ("Query '$query' failed with error message: \"" . mysql_error () . '"');

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo  	"<a href=\"script2.php?item={$row['foldername']}\" onclick=\"load('script2.php?item={$row['foldername']}','listings');return false;\">{$row['foldername']}</a><br />";	
}

 

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.