Jump to content

SELECT And Sort


Mr_T

Recommended Posts

Hey, I'm trying to make a script which will match a textbox value against a database, and then sort <=.

 

I've got this so far;

 

<input name="search" id="search" type="text">
<input name="year" id="year" type="text">

$search = $_GET['search'];
$year = $_GET['year'];

SELECT * FROM table WHERE MATCH(Place, Land, Yeartime) AGAINST('%$search%' IN BOOLEAN MODE)

SELECT * FROM table WHERE Yeartime <= '%$year%'

 

This is what I want to accomplish, but the line doesn't seem to work?

 

SELECT * FROM table WHERE MATCH(Place, Land, Yeartime) AGAINST('%$searsearch%' IN BOOLEAN MODE) AND Yeartime <= '%$year%' ORDER BY Yeartime";

 

Link to comment
Share on other sites

Nevermind I fixed it :) But I got another problem, when i'm trying to display the value in one of the columns in the database the value gets cut in half? I'm guessing there is a character limit. I've tried raising VARCHAR(30) to VARCHAR(60), nothing happened so i'm guessing the problem isn't there?

 

$shortDescription = substr($description, $searchPosition, 150);

 

I just realized that its this line that has to change. What do I change it to? 0? or simply just remove "150" ?

Link to comment
Share on other sites

What the hell, I removed this section and even raised VARCHAR from 30 to 255 and it still cuts my results?

 

$description = $result2['category'];

$searchPosition = strpos($description, $search);

$shortDescription = substr($description, $searchPosition, 150);

Link to comment
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.