but please i have another problem in mysql query my select is i have records conatins :5,10,15 days every time i choose +/-7 days which has the values 7 it gives me 0 and when i select +/14 which has the value 14 its gives me the days 5,15 and when i select +/-21 its gives me the days 5 why???????? and there is no sql error i think mysql query contains something wrong ???
hmm.. i dont see any problem with your post... i tried your script and it works, and with accurate output.. you might want to check some . , ; chars on your script... ^^,
Have you debugged it by printing the $query to the screen to make sure it is what you expect. Check if you choose +/-7 your $query actually looks correct.
If days is an integer ... good practice ... don't put the single quotes. To debug ... find out what $days is ... Hacking Info: Also make sure to validate $days before to run the query ... otherwise, someone could hack and post your form with different values and hack into your database.
<?php mysql_connect("localhost","root",""); mysql_select_db("practice"); if($_POST) { $days = $_POST['days']; $query2="select user from rklb_user_accounts where id >= '". $days ."'"; $query = mysql_query($query2); while($a = mysql_fetch_array($query)) { echo $a['user']; } } ?> <body> <form method="POST"> <select name="days" iid="days"> <option value="7">+/-7 days</option> <option value="14">+/-14 days</option> <option value="21">+/-21 days</option> </select> <input type="submit" /> </form> </body> here's my quick script..
Ok tthnxxxx cocacolafun i was putting it as varchar in my database and when i changed it to int it worked just fine thnxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx