Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About teensicle

  • Rank
  • Birthday 05/24/1992

Previous Fields

  • Languages
    English, Jamaican Patios

Contact Methods

  • MSN
  • Website URL
  • Yahoo
  • Skype

Profile Information

  • Location
  • Interests
    Cloud Computing
  1. Okay so i tried the code and the execution works and i can positively see that php script request was made. However i am getting an "Undefined error" for the post variable "check" i.e $_POST["check"] and an invalid argument error for the "foreach" array assignment loop which i suspect happened because the post data was not in it's correct form. Any suggestions ? <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script><script>$(document).ready(function(){ $("#img").click(function(){ var chkbx = $("#your_form").serialize(); $.post("sql_delete.php",chkbx,function(data){ alert(data); }); });});</script></head><body><form id="#your_form"> Check Box: <input type="checkbox" name="check[]" value="1"><br> Check Box: <input type="checkbox" name="check[]" value="2"><br> Check Box: <input type="checkbox" name="check[]" value="3"><br> Check Box: <input type="checkbox" name="check[]" value="4"><br></form><img id = "img" src="http://blogs.learnnowonline.com/Portals/153597/images/jquery1.png" width="64" height="64"></body></html> <?php //Look out for SQL-injections $message_id = mysql_real_escape_string($_POST["check"]); if(isset($message_id)){ foreach($message_id as $id){ $query = mysql_query("DELETE FROM `chj_messages` WHERE `message_ID` = '$id'")or die(mysql_error()); } } ?>
  2. Want to have the user select one or more checkboxes and then click a button to delete all the selected items. Doesn't seem to b working though <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>HTML/JS:</head><body><form id="#your_form"> Check Box: <input type="checkbox" name="check[]" value="1"> Check Box: <input type="checkbox" name="check[]" value="2"> Check Box: <input type="checkbox" name="check[]" value="3"> Check Box: <input type="checkbox" name="check[]" value="4"> <input type="image" src="http://blogs.learnnowonline.com/Portals/153597/images/jquery1.png" width="64" height="64"></form><script>$(document).ready(function(){ $("#your_form").click(function(){ $.get("sql_delete.php",$("#your_form").serialize(),function(response){ alert(response); }); });});</script></body></html> <?phprequire 'functions/init.php'; $messageid = $_POST['check']; foreach($messageid as $id) { $sql_statement = "DELETE FROM chj_messages WHERE message_ID = $id"; mysql_query($sql_statement); }?>
  3. So i know it's been a while but i'm back on the grind! . Can anyone suggest how i can include a option that will display "ALL" in a select box
  4. My new select option: Price <select name="price" size="0"> <option value="< 100000">Under $100,000</option><option value=">= 100000 AND `v_price` <= 250000">Between $100,000 and $250,000</option><option value=">= 250000 AND `v_price` <= 500000">Between $250,000 and $500,000</option><option value=">= 500000 AND `v_price` <= 750000">Between $500, 000 and $750,000</option><option value=">7500000">Over $750,000</option> </select> PHP CODE: $sql = sprintf("SELECT *FROM `chjadb_vehicles`WHERE `v_make` LIKE '$make'AND `v_year` = '$year'AND `v_trans` LIKE '$trans'AND `v_price` $priceAND `condition` LIKE '$cond'AND `b_style` LIKE '$b_style'"); Thanks it now works! i find that when i set a criteria and press submit the options reset itself. How can i control that? if you notice the make goes back to BMW, which is at the top of the select query list and also does the other options see example below: P.S ignore the horrible layout just trying to get the functionality working
  5. I am developing a website where by people can buy and sell new or used cars. I want to set up a simple filter using php and sql statements and also of course html select boxes (drop down options). I have gotten all the other options to work with help and trust me it has been greatly appreciated. However i have been trying to get the "price filter" to work and been getting no where. Below is what my select box in html look like. <select name="price" size="0"> <option value="100000">Under $100,000</option><option value="<?php echo " BETWEEN '100000' AND '250000' "?>">Between $100,000 and $250,000</option><option value=">250000<500000">Between $250,000 and $500,000</option><option value=">500000<750000">Between $500, 000 and $750,000</option><option value=">7500000">Over $750,000</option> </select> This is my $_POST statement for the price variable: $price = mysql_real_escape_string($_POST['price']); This is my sql statement: $sql = sprintf("SELECT * FROM `chjadb_vehicles` WHERE `v_make` LIKE '$make'AND `v_year` = '$year'AND `v_trans` LIKE '$trans'AND `condition` LIKE '$cond' AND `b_style` LIKE '$b_style' AND `v_price` '$price'"); After which i have a basic loop that should print the results. Now from what i understand (correct or not), when the user selects a specific option from the drop down menu the value from "option value" is passed to the $_POST statement. After which it should replace $price with the actual text BETWEEN '100000' AND '250000', completing the query statement. So the final statement printed from the sql statement should be: "SELECT * FROM `chjadb_vehicles` WHERE `v_make` LIKE '$make'AND `v_year` = '$year'AND `v_trans` LIKE '$trans'AND `condition` LIKE '$cond' AND `b_style` LIKE '$b_style' AND `v_price` BETWEEN '100000' AND '250000'"` However i get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''BETWEEN 100000 AND 250000'' at line 8 Any ideas as to where i went wrong? Thanks Regards,D. Ruddock
  6. i checked the main site and it has been a whole heap of help so far. However im not sure how to accomplish a specific task and im now stuck on this. I have the following query: SELECT * FROM chjadb_vehicles WHERE v_make ='$make' AND v_year= '$year' The following statement works fine. However what i want is to add more query criterias such as body type, transmission and thing like that. How do i set something like that. I tried doing it like this: SELECT * FROM chjadb_vehicles WHERE v_make ='$make', v_year= '$year', v_transmission = '$trans' Doesn't work however any help would be appreciated!
  • Create New...