Jump to content

Halisco

Members
  • Posts

    20
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Halisco's Achievements

Member

Member (2/5)

0

Reputation

  1. I have two seperate tables containing an customer_id that match when a customer purchases a particular type of fruit. I have a multi table 1 "customers": customer_id email phone 1 email1@email.com 555-111-1111 2 email2@email.com 555-222-2222 3 email3@email.com 555-333-3333 customer_id type 1 macintosh 1 galla 2 galla 2 jonagold 3 jonagold Here is a shorter version of my item list i use for selecting the type of fruit i want to search for. <select name=fruit_type[] multiple> <option value="macintosh">macintosh</option> <option value="gala">a</option> <option value="jonagold">jonagold</option> </select> I then take that list and join it $search_fruit = filter_var_array($_POST['fruit_type'], FILTER_SANITIZE_SPECIAL_CHARS); $fruit_types = join("','", $search_fruit ); Here is my SQL query $search_criteria = "" . "SELECT c.* " . "FROM customers AS c LEFT JOIN type AS p ON c.customer_id= p.customer_id" . "WHERE type NOT IN ('$fruit_types ') " . "GROUP BY c.customer_id, p.customer_id" . "ORDER BY customer_id Asc"; This works if I Just use IN for the customers i want to find that have purchased a particular type of apple but i am trying to search for customers that have never purchased a particular apple or multiple apples from my list. For example if i select just macintosh from the list customer 1 still show up as not purchasing that apple type because they have purchased an apple that is not a macintosh. Can anyone help me figure out how i accomplish this task?
  2. A question answered with a non helpful question. I used to use this forum several years ago and never had such ignorant comments from users. Thanks to those that have been trying to help. I think i will have to go to a forum where users understand people can be ignorant and need help..
  3. If you are not going to aid in teaching don't comment Being an A****ole does not help. Im no guru and i come here for help not to listen to people like you. Stay off my post.
  4. This is producing results for me however it is still not giving me results where every item selected has to be associated with the id. It still produces results if any of the id's have the selected items. $fruit_count = count($_POST['fruit']); $fruit_types = join("','",$_POST['fruit']); $fruit_results = $conn->query(" SELECT id FROM fruit WHERE fruit_name IN ('$fruit_types') GROUP BY id HAVING COUNT(1) = count($fruit_count) ");
  5. Jacques1 You comment is not of assistance with the actual resolution to my problem. please feel free to assist me with the actual question or i would appreciate you not post at all. I am here seeking assistance not insult. Is anyone else able to offer some assistance?
  6. I understand the injection is there and i posted a quick and dirty to avoid posting any other code. I have seen the exact code you have replied with on google and have tried using it already. If apple and banana are selected from my multiple selection I should only get id 1 and id 2 using my while statement. I think i have modified the code to represent what i need. The final number 3 you posted is a dynamic number depending on the amount of fruit type selected. When i try to echo the results i get a an error: $fruit_results = $conn->query("SELECT id FROM fruit WHERE fruit_name IN ('$fruit_type ') GROUP BY id HAVING COUNT(1) = count('$fruit_type ')"); while($row = $fruit_results ->fetch_assoc()) { echo $row['id']; } Call to a member function fetch_assoc() on boolean
  7. I have searched this on google and this forum and and struggling to figure this out. I have a table: | id | fruit_name | The id column is not unique i have several identical enstries and the name is also not unique and has several identical entries: | 1 | apple | | 2 | banana | | 2 | apple | | 1 | orange | | 3 | grapefruit | | 3 | apple | | 1 | banana | | 2 | peach | | 3 | peach | I have a multiple select list with the id="fruit" and using join to create a variable for my query: $fruit_type = join("','",$_POST['fruit']); $fruit_results = $conn->query("SELECT * FROM fruit WHERE fruit_name IN ('$fruit_type ')"); while($row = $fruit_results ->fetch_assoc()) { echo $row['id']; } This is giving me all the id of any row that has any type of fruit that is selected in the list. I am trying to the id's that contain all of the fruit selected not just one or the others. Can anyone help me out please? Thanks, Halisco
  8. Exactly what i was looking for !!!! Thankyou very much!!!!
  9. I hope i can explain this clearly. What i am doing is sending serveral <input> values using the <form method="get"> metohd. Its placing all my input vaues into the URL and i am taking that data and entering it into a databasae. What i am wondering is if i can somehow get the info from the URL into an array. The URL Looks like this: http://localhost/profile.php?ID=3096&EditSection=Personal&FirstName=Dion&LastName=Simons&AccountNum=549382 Here is my script: function UpdateInfo() { $con = mysql_connect("Host","User","Password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DbName", $con); mysql_query("UPDATE Table1 SET FirstName = '$_GET[FirstName]' WHERE ID = '$_GET[iD]'"); mysql_query("UPDATE Table1 SET LastName = '$_GET[LastName]' WHERE ID = '$_GET[iD]'"); mysql_query("UPDATE Table1 SET AccountNum= '$_GET[AccountNum]' WHERE ID = '$_GET[iD]'"); mysql_close($con); } As you can see all of the database fields have the same name as the _GET fields. Im trying to take the array created from the URL to use in thie function so i dont have to put a line of script for each field/_Get value. Can anyone help me out? I have not idea where to start with this one. Oh by the way these are not all the fields i am using there are over 30. I just used 3 to keep the post small.
  10. Is there a work around I can use to avoid getting this negative number. I have to use the dates in the database that are later then 2038.
  11. I have a experation script that works well until i get over approximately "10230" days. Once i get past that many days the value becomes negative. Any Ideas why this would happen? Here is my script: $BadDate = (( (strtotime($CertExp)) - (strtotime($todays_date)) ) / 60 / 60 / 24 ); if (($BadDate < 90 AND $BadDate > 0) OR ($BadDate < 0)){ $BadTh="thred"; $BadTd="tdred"; elseif ($BadDate == 0){ $BadTh="thred"; $BadTd="tdred"; }else{ $BadTh=""; $BadTd=""; }
  12. You're right actually. Use the GET method instead. Thankyou for your assistance!
  13. So your telling me there is no way to call a PHP function from within href without using javascript? If that is the case that should have been your original reply. Simply telling someone "thats javascript bro not PHP" is not a clear answer. I think you should learn some Forum etiquette. You may learn this one day when you ask a question about somthing that is not your Forte and someone wastes your time with snarky remarks. If you dont learn any furhter etiquette please do not reply to any of my future posts. It would be much appreciated. PS> thanks for possibly leading me in the right direction....
  14. Thanks for stating what i am doing wrong but not offering any input as a solution. come on now, let's not get nasty. We are all here volunteering help! If he doesnt know how to help me then dont bother posting a reply. And if he does know how to help and does not "volunteer" the info then dont bother replying then either. Ive been googling this for a while with no success and now with frustration with a reply from and A****le like him. So please if you dont have a positive or helpfull reply then don't bother. Forums are about helping not ridiculing people.
  15. Thanks for stating what i am doing wrong but not offering any input as a solution.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.