Jump to content

Reg Expresion Help


graham23s

Recommended Posts

Hi Guys,

 

in my search function if a user searches for a file named:

 

something.somethinelse.pdf

 

the concatenation symbol seems to only allow the first word to be searched for, i was going to (if possible) use a reg expression to tell search to ignore the (.) is that possible at all?

 

if (eregi('.', $keywords)) {
    echo "if the string contains a (.) what to do?";
}

 

thanks guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/54940-reg-expresion-help/
Share on other sites

Hi Chigley,

 

no problem mate here it is:

 

<?php
    // Check to see if there are submitted keywords...///////////////////////////////
    if (isset($_GET["keywords"]) && ($_GET["keywords"] != "")) {

	// Require a database connection...//////////////////////////////////////////////
	require("includes/db_connection.php");

	// Capture our search words and remove url encoding...///////////////////////////
	$keywords = urldecode($_GET["keywords"]);

	// Create our query, including our keywords...///////////////////////////////////
	$sql  = "SELECT id,file_name,cat_id,description,date_added ";
	$sql .= "FROM `uploaded_files` ";
	$sql .= "WHERE `file_name` LIKE '%$keywords%' OR `description` LIKE '%$keywords%'";
	$sql .= "ORDER BY `date_added` ASC ";

	// Create a result set from our query.../////////////////////////////////////////
	$rs = mysql_query($sql) or die(mysql_error());

	// number of results...//////////////////////////////////////////////////////////
	$num_res = mysql_num_rows($rs);
?>

 

thanks mate

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/54940-reg-expresion-help/#findComment-271706
Share on other sites

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.