![]() |
Function for exact range - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Function for exact range (/showthread.php?tid=49531) |
Function for exact range - El Forum - 02-23-2012 [eluser]Fantass[/eluser] Hello, heres the trouble if i want a exact range for example 1-10 do specific function this way Code: <?php But the real trouble is i had to do arround 2 thousand if's by this way, theres another way to do this specifing Example range 20-31 do this.. etc,? Thanks alot. Function for exact range - El Forum - 02-23-2012 [eluser]CroNiX[/eluser] Code: if ($input >= 20 AND $input <= 31) echo 'OK'; Function for exact range - El Forum - 02-23-2012 [eluser]pbflash[/eluser] Code: if ($input >= 1 && $input <= 10) Function for exact range - El Forum - 02-24-2012 [eluser]Fantass[/eluser] Thanks brous! ![]() Function for exact range - El Forum - 02-24-2012 [eluser]Fantass[/eluser] [quote author="CroNiX" date="1330063315"] Code: if ($input >= 20 AND $input <= 31) echo 'OK'; [quote author="pbflash" date="1330063452"] Code: if ($input >= 1 && $input <= 10) Thank yo guys now can yo help me how do this query into MySql? THANKS ALOOOOOOOT Function for exact range - El Forum - 02-24-2012 [eluser]PhilTem[/eluser] How do you want to put it into MySQL? Make the query take care of this check like select only rows if some column's value is within that range? Have a look at http://dev.mysql.com/doc/refman/5.0/en/if-statement.html and http://www.java2s.com/Code/SQL/Flow-Control/UseIFinselectclause.htm for an example. Quick and dirty example: Code: SELECT name AS Name, category AS Category, Function for exact range - El Forum - 02-24-2012 [eluser]CroNiX[/eluser] Selecting Ranges: Code: SELECT fields FROM table WHERE field >= 20 AND field <= 31 Code: SELECT fields FROM table WHERE field BETWEEN 20 AND 31 Function for exact range - El Forum - 02-27-2012 [eluser]Aken[/eluser] No offense here, but if you are running loops like THAT, you might want to stay away from CodeIgniter until you get a bit more familiar with PHP. You may be in over your head very quickly. Function for exact range - El Forum - 02-27-2012 [eluser]Fantass[/eluser] [quote author="Aken" date="1330327632"]No offense here, but if you are running loops like THAT, you might want to stay away from CodeIgniter until you get a bit more familiar with PHP. You may be in over your head very quickly.[/quote] Eventually. |