Mr_T Posted November 23, 2010 Share Posted November 23, 2010 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"; Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 23, 2010 Share Posted November 23, 2010 what doesn't seem to work about it? Quote Link to comment Share on other sites More sharing options...
Mr_T Posted November 23, 2010 Author Share Posted November 23, 2010 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" ? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 23, 2010 Share Posted November 23, 2010 if you increase the size of the field, the truncated data in the field will not re-appear. did you test the insert after increasing the field size? Quote Link to comment Share on other sites More sharing options...
Mr_T Posted November 23, 2010 Author Share Posted November 23, 2010 if you increase the size of the field, the truncated data in the field will not re-appear. did you test the insert after increasing the field size? What fields are you talking about? The ones in the database? Quote Link to comment Share on other sites More sharing options...
Mr_T Posted November 23, 2010 Author Share Posted November 23, 2010 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); Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 23, 2010 Share Posted November 23, 2010 this command will truncate $shortDescription from position $searchPosition to a length of 150: substr($description, $searchPosition, 150); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.