Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,143,218 members, 7,780,405 topics. Date: Thursday, 28 March 2024 at 01:44 PM

PHP Gurus - Please Help With A Form. Thank You - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / PHP Gurus - Please Help With A Form. Thank You (1616 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)

(1) (Reply) (Go Down)

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:
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.

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:
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.


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:
what is the data type for your DOB column?

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:


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.


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:


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.



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:
Or u can post wat u want ur page to do and i will give u a sample php code.

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:


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.
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:


My DOB data type is 'date'.
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:
good evening, what columns do u want to receive?
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:
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


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:



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
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:
you're welcome
you can use html, css and javascript to do that

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*"wink; // Notifying validation
event.preventDefault();
} else {
return true;
}
}
/*-------------------------------------------------------------------------------*/
// Function that executes on click of first next button
function next_step1() {
document.getElementById("first"wink.style.display = "none";
document.getElementById("second"wink.style.display = "block";
document.getElementById("active2"wink.style.color = "red";
}
//Function that executes on click of first previous button.
function prev_step1() {
document.getElementById("first"wink.style.display = "none";
document.getElementById("second"wink.style.display = "block";
document.getElementById("active1"wink.style.display = "red";
document.getElementById("active2"wink.style.display = "gray";
}
// Function that executes on click of second next button
function next_step2() {
document.getElementById("second"wink.style.display = "none";
document.getElementById("third"wink.style.display = "block";
document.getElementById("active3"wink.style.color = "red";
}
//Function that executes on click of second previous button.
function prev_step2() {
document.getElementById("second"wink.style.display = "none";
document.getElementById("third"wink.style.display = "block";
document.getElementById("active2"wink.style.display = "red";
document.getElementById("active3"wink.style.display = "gray";
}
// Function that executes on click of third next button
function next_step3() {
document.getElementById("third"wink.style.display = "none";
document.getElementById("fourth"wink.style.display = "block";
document.getElementById("active4"wink.style.color = "red";
}
//Function that executes on click of third previous button.
function prev_step3() {
document.getElementById("third"wink.style.display = "none";
document.getElementById("fourth"wink.style.display = "block";
document.getElementById("active3"wink.style.display = "red";
document.getElementById("active4"wink.style.display = "gray";
}
// Function that executes on click of fourth next button
function next_step4() {
document.getElementById("fourth"wink.style.display = "none";
document.getElementById("fifth"wink.style.display = "block";
document.getElementById("active5"wink.style.color = "red";
}
//Function that executes on click of fourth previous button.
function prev_step4() {
document.getElementById("fourth"wink.style.display = "none";
document.getElementById("fifth"wink.style.display = "block";
document.getElementById("active4"wink.style.display = "red";
document.getElementById("active5"wink.style.display = "gray";
}
// Function that executes on click of fifth next button
function next_step5() {
document.getElementById("fifth"wink.style.display = "none";
document.getElementById("sixth"wink.style.display = "block";
document.getElementById("active6"wink.style.color = "red";
}
//Function that executes on click of fifth previous button.
function prev_step5() {
document.getElementById("fifth"wink.style.display = "none";
document.getElementById("sixth"wink.style.display = "block";
document.getElementById("active5"wink.style.display = "red";
document.getElementById("active6"wink.style.display = "gray";
}

(1) (Reply)

Techgeek12 Is A Scammer And A Thief. You All Be Warned. / Have You Tried Out Angularjs(mvc Framework) / Download Free Android Apps With Free Android Apps Development Tutorial

(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. 49
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.