Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,183,589 members, 7,921,242 topics. Date: Wednesday, 14 August 2024 at 08:49 PM |
Nairaland Forum / Science/Technology / Programming / PHP Gurus - Please Help With A Form. Thank You (1686 Views)
Needs A Registration Page With A Form Print Out / New To Python, Gurus Please Help Solve These Challenges. Thanks. / Java Gurus Please I Need This Little Assignment Solved ''appreciation Involved" (2) (3) (4)
PHP Gurus - Please Help With A Form. Thank You by success9(m): 3:29pm On Jul 13, 2017 |
Hello gurus (I doff my hat). I'm having an issue with a form that I initially thought will be easy to deal with (I'm just learning PHP). I created a list of fictitious users with the following data stored in my database: username, password, email, phone, sex, date of birth, country, state and some other columns with boolean values. This is the form: <Form> <Select type="text" name="sex"> <Option value="1">Male</option> <Option value="2">Female</option> </select> <Br> <Input type="number" name="from" value="" placeholder="from"> <Input type="numbe" name="to" value="" placeholder="to"> <Input type="text" name="country" value="" placeholder="country"> <Input type="text" name="state" value="" placeholder="state"> <Input type="submit" name="submit" value="Search"> I have tried with the little knowledge I have to query my database but I keep getting error with my age calculation. How do I go about it? Secondly, how do I get it to return list of users with matched results with each list coming with an array(username, profile pic, location and age). I will be grateful. |
Re: PHP Gurus - Please Help With A Form. Thank You by Caustics: 3:44pm On Jul 13, 2017 |
success9:what is the data type for your DOB column? |
Re: PHP Gurus - Please Help With A Form. Thank You by noblenadis(m): 4:22pm On Jul 13, 2017 |
success9: A lot of things are not quire clear with your post. 1. You said "I have tried with the little knowledge I have to query my database but I keep getting error with my age calculation." The question is, are you calculating their age or do you want to retrieve their submitted 'age data' from the form filed during submission. If you are calculating their age, you may need to provide the parameters and PHP code snippet you are using, if possible the exact error message after clicking the submit button. 2. For the second question, you can simply query the database using SELECT statement to retrieve all or specific columns from the database. eg, if your table name is 'users' you could write: SELECT * FROM users; This simple statement will retrieve everything from the database table 'users'. To display it to the browser, simply assign the query result to a variable and use the PHP echo function to display it. I hope this helps. |
Re: PHP Gurus - Please Help With A Form. Thank You by success9(m): 5:57pm On Jul 13, 2017 |
Caustics: My DOB data type is 'date'. |
Re: PHP Gurus - Please Help With A Form. Thank You by Nobody: 6:11pm On Jul 13, 2017 |
Bro i suggest u take a MySQL course. Its not dat bulky and learn php mysqli too. 1 Like |
Re: PHP Gurus - Please Help With A Form. Thank You by Nobody: 6:14pm On Jul 13, 2017 |
Or u can post wat u want ur page to do and i will give u a sample php code. |
Re: PHP Gurus - Please Help With A Form. Thank You by success9(m): 6:23pm On Jul 13, 2017 |
noblenadis: I want to retrieve from 'users' in my database on the data provided by loggedInUsers. I can calculate age if I'll provide 'dob' manually but I can't equate the 'age' variable provided in the 'from' and 'to' fields to retrieve the corresponding DOBs that will make up that age in my database. For instance, $from = (to the corresponding code). Meanwhile, $from is the data provided in the 'from' field in the form. ($from - $to) will be an array for DOBs equal to 'from' to 'to' variables. Thanks. |
Re: PHP Gurus - Please Help With A Form. Thank You by oluwadubem: 8:45pm On Jul 13, 2017 |
success9: Mr success gudpm,me am not that good yet but I think if is all about retrieve all you need is a "select" statements,someone have also suggested that for you here,what do yu really mean by "dob" i blive that ur prob is not that hard but the prob is how asked it,bcuz it will be hard for some1 to figure out what exactly ur trying to do with the form according to ur explanation....thanks #peace# |
Re: PHP Gurus - Please Help With A Form. Thank You by success9(m): 9:26pm On Jul 13, 2017 |
justanALIAS: Thanks. I want my page to be able to conduct a search of my database for a list of certain users the way a dating website does. |
Re: PHP Gurus - Please Help With A Form. Thank You by Nobody: 10:14pm On Jul 13, 2017 |
success9:good evening, what columns do u want to receive? |
Re: PHP Gurus - Please Help With A Form. Thank You by Caustics: 10:27pm On Jul 13, 2017 |
success9:i dont know if you have sloved your problem but one way to tackle your problem is a create a code that calculates the age from the dob and stores it in the database under a different age column. From your form eg. $from=18 and $to=25. then sql query will be. "Select from users where age between $from and $to" while adding the other conditions for gender, country and state. hope this helps |
Re: PHP Gurus - Please Help With A Form. Thank You by success9(m): 11:47am On Jul 14, 2017 |
justanALIAS:I want the search to return profileImage, username, age, sex and location. |
Re: PHP Gurus - Please Help With A Form. Thank You by oluwadubem: 1:07pm On Jul 14, 2017 |
"select * from mydb where (age between 18 and 25) and( country=us and state=California) order by myid desc" if(mysql_num_rows(myselect)>0){ while($retrive=mysql_fetch_assoc(myselect)){ echo $retrive['profile_image'] echo $retrive['user_name']; echo $retrive['age']; //and many more you want to echo out.....// } else{ echo 'no result found yet'; } lol.....myown idea doh, #peace# 1 Like |
Re: PHP Gurus - Please Help With A Form. Thank You by success9(m): 6:20pm On Jul 14, 2017 |
Caustics: Yes, it helped like magic. Thanks a lot. However, I have a long form that I want to divide into pages. So users, can fill one page and then save the data. Afterwards, users will click next to go on to the next page until they eventually submit on the last page. I don't want them submitting per page. Thanks |
Re: PHP Gurus - Please Help With A Form. Thank You by Caustics: 6:22pm On Jul 14, 2017 |
success9:you're welcome you can use html, css and javascript to do that |
Re: PHP Gurus - Please Help With A Form. Thank You by success9(m): 1:13pm On Jul 15, 2017 |
Caustics: I know...but I have no knowledge of Javascript whatsoever. I got this from the internet but it doesn't seem to be working properly. /*------------------------Validation Function---------------------------------*/ var count = 0; //To count blank fields function validation(event) { var radio_check = document.getElementsByName('gender'); //Fetching radio button by name var input_field = document.getElementsByClassName('text_field'); //Fetching all inputs with same class name text_field and an html tag textarea var text_area = document.getElementsByTagName('textarea'); //Validating radio button if (radio_check[0].checked == false && radio_check[1].checked == false) { var y = 0; } else { var y = 1; } //For loop to count blank inputs for (var i = input_field.length; i> count; i--) { if (input_field[i - 1].value == '' || text_area.value == '') { count = count + 1; } else { count = 0; } } if (count != 0 || y == 0) { alert("*All Fields are mandatory*" // Notifying validation event.preventDefault(); } else { return true; } } /*-------------------------------------------------------------------------------*/ // Function that executes on click of first next button function next_step1() { document.getElementById("first".style.display = "none"; document.getElementById("second".style.display = "block"; document.getElementById("active2".style.color = "red"; } //Function that executes on click of first previous button. function prev_step1() { document.getElementById("first".style.display = "none"; document.getElementById("second".style.display = "block"; document.getElementById("active1".style.display = "red"; document.getElementById("active2".style.display = "gray"; } // Function that executes on click of second next button function next_step2() { document.getElementById("second".style.display = "none"; document.getElementById("third".style.display = "block"; document.getElementById("active3".style.color = "red"; } //Function that executes on click of second previous button. function prev_step2() { document.getElementById("second".style.display = "none"; document.getElementById("third".style.display = "block"; document.getElementById("active2".style.display = "red"; document.getElementById("active3".style.display = "gray"; } // Function that executes on click of third next button function next_step3() { document.getElementById("third".style.display = "none"; document.getElementById("fourth".style.display = "block"; document.getElementById("active4".style.color = "red"; } //Function that executes on click of third previous button. function prev_step3() { document.getElementById("third".style.display = "none"; document.getElementById("fourth".style.display = "block"; document.getElementById("active3".style.display = "red"; document.getElementById("active4".style.display = "gray"; } // Function that executes on click of fourth next button function next_step4() { document.getElementById("fourth".style.display = "none"; document.getElementById("fifth".style.display = "block"; document.getElementById("active5".style.color = "red"; } //Function that executes on click of fourth previous button. function prev_step4() { document.getElementById("fourth".style.display = "none"; document.getElementById("fifth".style.display = "block"; document.getElementById("active4".style.display = "red"; document.getElementById("active5".style.display = "gray"; } // Function that executes on click of fifth next button function next_step5() { document.getElementById("fifth".style.display = "none"; document.getElementById("sixth".style.display = "block"; document.getElementById("active6".style.color = "red"; } //Function that executes on click of fifth previous button. function prev_step5() { document.getElementById("fifth".style.display = "none"; document.getElementById("sixth".style.display = "block"; document.getElementById("active5".style.display = "red"; document.getElementById("active6".style.display = "gray"; } |
(1) (Reply)
C++ Book / What Can I Do With Command Prompt? / Instagram's Source Code & 2 Parts On How To Make An App Like Instagram
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 52 |