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"; Link to comment https://forums.phpfreaks.com/topic/219602-select-and-sort/ 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? Link to comment https://forums.phpfreaks.com/topic/219602-select-and-sort/#findComment-1138564 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" ? Link to comment https://forums.phpfreaks.com/topic/219602-select-and-sort/#findComment-1138676 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? Link to comment https://forums.phpfreaks.com/topic/219602-select-and-sort/#findComment-1138680 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? Link to comment https://forums.phpfreaks.com/topic/219602-select-and-sort/#findComment-1138684 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); Link to comment https://forums.phpfreaks.com/topic/219602-select-and-sort/#findComment-1138700 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); Link to comment https://forums.phpfreaks.com/topic/219602-select-and-sort/#findComment-1138719 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.