Page 1 of 1
Little lost here!
Posted: Mon Nov 08, 2010 2:52 pm
by WFPS
Hi Everyone!
I need some help, but I think it will be a cake walk for most of you.
I'm looking to build a web page that just contains a list of people who sign the list. You write your name and perhaps location in a box, summit and then it shows up on the list. Very simple. Maybe about 200 names on the list with pages for other names.
Example;
3. Kevin Pereira San Jose, Ca (Last person to submit name)
2. Timmy Parker Las Vegas, NV
1. John Doe New York, NY
Also, I would like a box to for everyone to enter in an email address that I keep without the email showing up on the list.
Can anyone help me? I am a little lost here! I have php my admin in my hosting package.
Re: Little lost here!
Posted: Mon Nov 08, 2010 3:33 pm
by Jonah Bron
We can guide you, but we can't (won't) do it for you. You need to create a table with four columns: ID, name, location, and email.
http://php.about.com/od/learnmysql/ss/create_tables.htm
Next, create a form containing the fields you want (name, location, email).
http://w3schools.com/html/html_forms.asp
Lastly, create a script that takes the data from the form, and inserts it into the database.
http://w3schools.com/php/php_forms.asp
http://w3schools.com/php/php_mysql_insert.asp
Additionally, you can get the most recent names (like you showed) on the page with the form:
http://w3schools.com/php/php_mysql_select.asp
http://php.about.com/od/mysqlcommands/g/Limit_sql.htm
Re: Little lost here!
Posted: Mon Nov 08, 2010 7:38 pm
by WFPS
Thanks so much for that!! I've been working very hard on this.
I'm a little stuck on this. When I submit the forum, the table in the database shows an empty box. The information is not showing up, but Its obviously connecting to the database. Any help here? What could be wrong?
Re: Little lost here!
Posted: Mon Nov 08, 2010 8:47 pm
by califdon
WFPS wrote:Thanks so much for that!! I've been working very hard on this.
I'm a little stuck on this. When I submit the forum, the table in the database shows an empty box. The information is not showing up, but Its obviously connecting to the database. Any help here? What could be wrong?
Impossible to guess without seeing your code.
Re: Little lost here!
Posted: Mon Nov 08, 2010 9:01 pm
by WFPS
I actually got it going. Thanks though!
Re: Little lost here!
Posted: Mon Nov 08, 2010 10:07 pm
by WFPS
Ok new problem I can't get around,
I can only list two fields on my website and can not display the 3rd from the database, (location)
Right now I am only displaying id and name, how do I add location?
Code: Select all
$result = mysql_query("SELECT * FROM people");
while($row = mysql_fetch_array($result))
{
echo $row['id'] . " " . $row['name'];
echo "<br />";
}
mysql_close($con);
?>
scottayy wrote:Added PHP Code formatting tags.
Re: Little lost here!
Posted: Mon Nov 08, 2010 10:30 pm
by s.dot
All of your information is now available in $row.
So you would have $row['id'], $row['name'], $row['location'], and $row['email'] available to you
$row is an array with the table field names as keys.
Re: Little lost here!
Posted: Mon Nov 08, 2010 11:02 pm
by WFPS
Mind helping me with the code? I can't seem to get it right! So frustrating. Although I only started working with php yesterday
Re: Little lost here!
Posted: Tue Nov 09, 2010 12:39 am
by s992
WFPS wrote:Mind helping me with the code? I can't seem to get it right! So frustrating. Although I only started working with php yesterday
You just need to echo $row['location'] along with the rest of the information.
Re: Little lost here!
Posted: Tue Nov 16, 2010 4:01 pm
by WFPS
Got it working! Thanks Everyone!
One last question, how do I get the last entrees to show on the top instead of the bottom? Also, how do I create pages for people to scroll through earlier entrees?
Re: Little lost here!
Posted: Tue Nov 16, 2010 4:38 pm
by s992
You can modify your query to sort them: "SELECT * FROM people SORT BY id DESC"
As far as paging the results, that's something you should probably Google - there's a few tutorials out there on it. Good luck!