Little lost here!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
WFPS
Forum Newbie
Posts: 6
Joined: Mon Nov 08, 2010 2:48 pm

Little lost here!

Post 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.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Little lost here!

Post 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
WFPS
Forum Newbie
Posts: 6
Joined: Mon Nov 08, 2010 2:48 pm

Re: Little lost here!

Post 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?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Little lost here!

Post 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.
WFPS
Forum Newbie
Posts: 6
Joined: Mon Nov 08, 2010 2:48 pm

Re: Little lost here!

Post by WFPS »

I actually got it going. Thanks though!
WFPS
Forum Newbie
Posts: 6
Joined: Mon Nov 08, 2010 2:48 pm

Re: Little lost here!

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Little lost here!

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
WFPS
Forum Newbie
Posts: 6
Joined: Mon Nov 08, 2010 2:48 pm

Re: Little lost here!

Post 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
s992
Forum Contributor
Posts: 124
Joined: Wed Oct 27, 2010 3:06 pm

Re: Little lost here!

Post 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.
WFPS
Forum Newbie
Posts: 6
Joined: Mon Nov 08, 2010 2:48 pm

Re: Little lost here!

Post 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?
s992
Forum Contributor
Posts: 124
Joined: Wed Oct 27, 2010 3:06 pm

Re: Little lost here!

Post 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!
Post Reply