I am writing a code in which i need to find a value in my MySQL database. If the value is not there, however, I want the first value that is listed listed below my search value.
A better way would be to use sort to sort against the results. This would only work if you are looking for a single value though.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
$get = "SELECT myfield FROM mytable WHERE myfield <= myvalue ORDER BY myfield DESC LIMIT 1";
$search = mysql_query($get) or die(mysql_error());
$file = mysql_result($search, 0);
echo "
$file";
Must read Review for Serious PHP Developers
NuSphere PhpED 5.5
: The Staff of php-editors.com recently spent a few days working with NuSphere
PhpED 5.5
(a popular PHP IDE) and
NuCoder 2.0
(a PHP Encoding Utility), read up on all the details.