Jump to content

php mysql search


pjheliking

Recommended Posts

Hi,

 

I am doing a project for uni and need help as its the only thing i am stuck on. Im doing a little linking site which is not due for 3 weeks so started it a couple of hours ago and well needing help

 

I have decided to do a linking site for tv movies but i have only put 2 examples on the server as im not wanting sued!!

 

Anyways unless you do the exact search scrubs or lee evans you wont see results what I need to be able to do is query the mysql database and basicly the closest match gets displayed. I have done everything else to allow for this but i have been looking into the match sql query but i have a feeling im way off track. http://tvlinks.ctc-media.co.uk

 

Can you give me any advice or point me in the redirection ...

 

thanks

 

in advance  ;)

Link to comment
https://forums.phpfreaks.com/topic/126820-php-mysql-search/
Share on other sites

thanks peeps..

 

not solved but great...

 

the first bit of code didnt work :( the second shows everything from the database :( you have gave me something to work on thanks

 

heres my code

$tvlink = mysql_pconnect($hostname_tvlink, $username_tvlink, $password_tvlink) or trigger_error(mysql_error(),E_USER_ERROR);

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_link = "-1";
if (isset($_POST['title'])) {
  $colname_link = $_POST['title'];
}
mysql_select_db($database_tvlink, $tvlink);
$query_link = sprintf("SELECT * FROM linker WHERE tags LIKE '$disp'; ", GetSQLValueString($colname_link, "text"),GetSQLValueString("%" . $colname_link . "%", "text"));
$link = mysql_query($query_link, $tvlink) or die(mysql_error());
$row_link = mysql_fetch_assoc($link);
$totalRows_link = mysql_num_rows($link);

Link to comment
https://forums.phpfreaks.com/topic/126820-php-mysql-search/#findComment-655987
Share on other sites

mmmmmm im on the right track me thinks but it will have to wait...... http://tvlinks.ctc-media.co.uk/find.php thats where the search is i have implamented all that was said and wat i have picked up in tutorials online  for example try lee evans it will give you the links. Try lee nope not working.. I was hoping to use a tagging system but i think it will be a drop down search array now :(

 

 

Link to comment
https://forums.phpfreaks.com/topic/126820-php-mysql-search/#findComment-656005
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.