Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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