Jump to content

thara

Members
  • Posts

    604
  • Joined

Everything posted by thara

  1. @Barand, I am using checkboxes to select their body types, hair colors and ethnicity. Practically users can not have more ethnicity but body type and hair colors may have more than one. On this situation they can select more than one option using those checkboxes. Thats why I use comma separated string in "match_info" table.
  2. I have a table and it looks like this, mysql> select * from match_info; +---------------+---------+------------+-------------+-----------+ | match_info_id | user_id | body_types | hair_colors | ethnicity | +---------------+---------+------------+-------------+-----------+ | 1 | 1 | 1,5,9,13 | 1,5,9,13 | 2,6,10 | | 2 | 2 | 1,5,9,13 | 5 | 1,5,9 | +---------------+---------+------------+-------------+-----------+ I have used 3 tables for `body_types`, `hair_colors` and `ethnicity` with `id` and `name` columns in each table. Using above I need to select all values for particular user. Like this. Body Type: `Skinny, Muscular, Large, Ripped` Hair Color: `Blonde, Dark Brown, Strawberry Blonde, Dark Blonde` etc.... Can anybody tell me how I make a select query to get result as above. And also I would like to know is this database design is good or not? Hope somebody may help me out. Thank you.
  3. I am not clear about this can you kindly explain it? and why didn't you include "sex" in where clause? Thank you.
  4. Now I fixed the error and its working.. But still no idea how to do this My input check something like this : // check "I AM A" dropdown: if (!empty($_POST['iam'])) { $iam = $_POST['iam']; $iam = filter_var($iam, FILTER_SANITIZE_STRING); //echo $iam; } else { $iam = ''; } // check "Seeking" dropdown: if (!empty($_POST['seeking'])) { $seeking = $_POST['seeking']; $seeking = filter_var($seeking, FILTER_SANITIZE_STRING); $seeking = trim($seeking); if ($seeking == "Man") { $sex = "Male"; } else { $sex = "Female"; } //echo $seeking; } else { $seeking = ''; } // check "Age Min" dropdown: if (!empty($_POST['age_min'])) { $ageMin = (int) $_POST['age_min']; //echo $ageMin; } else { $ageMin = 18; } // check "Age Max" dropdown: if (!empty($_POST['age_max'])) { $ageMax = (int) $_POST['age_max']; //echo $ageMax; } else { $ageMax = 30; } // check "Country" dropdown: if (!empty($_POST['country'])) { $countryId = (int) $_POST['country']; //echo $countryId; } else { $countryId = ''; }
  5. @Barand, This is how I tried it. But I cannot get any records, $q = "SELECT u.user_id , u.username , u.email , u.dob , u.sex , u.whoami , u.about_you , u.age_range , h.centimeters , u.city , c.country_code , i.image , i.image_path FROM users u INNER JOIN height h ON h.id = u.height_id INNER JOIN countries c ON c.id = u.country_id LEFT JOIN image_info i ON i.user_id = u.user_id AND i.image_type = 'primary' WHERE TIMESTAMPDIFF(YEAR, dob, CURDATE()) >= '{$ageMin}' AND TIMESTAMPDIFF(YEAR, dob, CURDATE()) <= '{$ageMax}' AND u.sex = '{$sex}' AND u.country = '{$countryId}' ORDER BY u.date_registered DESC"; Can you tell what is the wrong with this? Thank you.
  6. @Barand, how would be the select query if all form fields are optional?
  7. @fastsol, Sorry of my mistake, I can use date for DOB column. I changed it. So any idea to create this select query?
  8. @fastsol, I am using 3 dropdown to select users DOB. then I format that 3 values to create DOB and its output is like this 'yyyy-mm-dd'. Thats why I use VARCHAR datatype for DOB.
  9. I want to make a select query to search seeking person between min and max ages. This is how search values comes from my search form. Array ( [iam] => Man [seeking] => Woman [age_min] => 18 [age_max] => 19 [country_id] => 25 ) I have stored these values in two mysql tables. One is `user` and other one is `Countries`. My problem is there is not a column in user table to store user's age. Age is calculating according to the users Date of Birth and user table have a column to store users DOB. My `users` table something like this: CREATE TABLE IF NOT EXISTS users ( user_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, country_id SMALLINT UNSIGNED NOT NULL, username VARCHAR(20) NOT NULL, email varchar(40) NOT NULL, first_name VARCHAR(30) DEFAULT NULL, sex ENUM('Male', 'Female') DEFAULT 'Male', dob VARCHAR(10) NOT NULL, address VARCHAR(40) DEFAULT NULL, city VARCHAR(25) NOT NULL, last_login TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', date_registered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (user_id), UNIQUE (email), UNIQUE (username) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; In country table it has `country_id` and `country_name`. So. Can I know is there a way to do this using MySql `SELECT` query. Hope somebody may help me out. Thank you.
  10. @Barand, Can we modify above function to display selected="selected" for selected option.
  11. Can I see database design for this ?
  12. I am developing a dating website. In that project I use a mysql table named "users" and for this table I have used ENUM datatype for many columns. my "users" table looks like this : CREATE TABLE IF NOT EXISTS users ( user_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, country_id SMALLINT UNSIGNED NOT NULL, username VARCHAR(20) NOT NULL, password CHAR(128) NOT NULL, salt CHAR(128) NOT NULL, email varchar(40) NOT NULL, first_name VARCHAR(30) DEFAULT NULL, last_name VARCHAR(30) DEFAULT NULL, sex ENUM('Male', 'Female') DEFAULT 'Male', dob VARCHAR(10) NOT NULL, mobile VARCHAR(12) DEFAULT NULL, address VARCHAR(40) DEFAULT NULL, address_two VARCHAR(40) DEFAULT NULL, city VARCHAR(25) NOT NULL, whoami VARCHAR(80) NOT NULL, looking_for ENUM('Short-term','Long-term','Marriage','Dating','Friends/Hang Out','Intimate Encounter','Talk/Email/Pen Pal','Activity Partner') DEFAULT 'Dating', ethnicity ENUM('White/Caucasian','Black/African','Hispanic/Latino','Asian','Native American','Middle Eastern','East Indian','Pacific Islander','Mixed Race') DEFAULT NULL, marital_status ENUM('Never Married','Divorced','Widowed','Separated','In a Relationship','Not Single/Not Looking') DEFAULT NULL, religion ENUM('Atheist','Buddhist/Taoist','Christian/Catholic','Christian/Protestant','Christian/LDS','Christian/Other','Hindu','Jewish','Muslim/Islamic','New Age','Non-religious','Agnostic','Spiritual but not religious','Other Religion') DEFAULT NULL, body_type ENUM('Skinny','Slim/Slender','Fit/Athletic','Toned & Firm','Muscular','Ripped','Modelesque','Average','Proportional','Curvy','Few extra pounds','Full Figured','Stocky','Husky','Voluptuous','Big and Beautiful','Large','Disabled') DEFAULT NULL, hair_color ENUM('Auburn','Red','Stawberry Blonde','Platinum Blonde','Blonde','Dark Blonde','Light Brown','Medium Brown','Dark Brown','Black','Radically Dyed','Salt & Pepper','Partial Gray','Gray','Silver/White','Bald/Shaved') DEFAULT NULL, drink ENUM('Never','Rarely','Occasionally','Socially','Regularly','Gave it up') DEFAULT NULL, smoke ENUM('Never','Socially','Regularly','Trying To Quit') DEFAULT NULL, headline VARCHAR(100) DEFAULT NULL, about_user TEXT DEFAULT NULL, ideal_match_info TEXT DEFAULT NULL, last_login TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', date_registered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (user_id), UNIQUE (email), UNIQUE (username) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; My question is, ENUM datatype I have used in this table is correct or not. If this is the correct way hope any body guid me for right direction. Thank you.
  13. Larry Ullman's php, mysql books definitly helped me to learn php and mysql...I recomend those for all who are just start to learn php
  14. i have only used notepad++ yet... it seems good enough for me..
×
×
  • 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.