Jump to content

PHP Noob


thinkbox00

Recommended Posts

Good day PHP masters!

 

Im new in programming and loves to learn PHP.

I want to create a DB driven site.. where you could manage a list (edit, add, delete) records.

 

I did check this tutorial

http://www.killersites.com/community/index.php?/topic/1969-basic-php-system-vieweditdeleteadd-records/

 

Its really helpful but for a beginner like me, surely its not so easy.

I wanted the OutPut to be in a column form (not a row form) on the TUT above , the output is on a row form.

I did try editing the script but its not working! its just making the site messy. Really messy.

 

I also wanted to add a Username and Password function but I am not sure .. how to do it.

 

The username and password function I wanted to include in the site works like this:

 

1. I did create a table for students.

2. Table has the information : First Name, Middle Name, Last Name , Address , ID number, Age, Birth Date

3. I wanted each "user" to have there own login: Username is there ID number and a Unique static password

4. My question is.. should I include the password information on the table? and set it to MD5?

5. Can you please give me a sample login script for this?

 

----------------

6. Is it possible for me to put grades on the Students Table? If yes, how to I do it? I am not just referring on adding a row for the "grades" I wanted to put there grades for "preliminary" , "quarterly" , "final grade".

OR ITS POSSIBLE IF I WILL JUST PUT THE GRADES ON A SEPARATE TABLE? AND USE THERE ID NUMBER (on the grades DB) TO SYNC THERE PERSONAL INFORMATION once they will have login to there account.

--if you could let me see some sample script for this, I will really appreciate it!

 

7. Can the DB table "students" accommodate 2000+ information for each (ex. First Name, Middle Name, Last Name , Address , ID number, Age, Birth Date)

I am just using a free shared hosting site for this test project.

 

 

Hope to hear from all of you. More Power to all!

Thanks

Jack

Link to comment
Share on other sites

"I wanted the OutPut to be in a column form (not a row form) on the TUT above"

 

Assuming I am understanding you correctly... this is going to be more difficult, because that's not how the records are stored in the database.

 

So you want to switch from something like this:

 

First Name: -------- Last Name:

FName1 ----------- LName1

FName2 ----------- LName2

FName3 ----------- LName3

FName4 ----------- LName4

 

to something like this?

 

First name: --- FName1 --- FName2 --- FName3 --- FName4

Last name: --- LName1 --- LName2 --- LName3 --- LName4

 

Any specific reason why? That seems unnecessarily complicated, and you're going to wind up with strange results (super wide rows) that may be unwieldy if you have a lot of data in your database. If I'm just not understanding you correctly, perhaps include an example?

 

For creating a login, yes, I would have a row in your database that would store their username and password information. I would give them a numeric id (like I did with the id in the tutorial) that will uniquely identify that user, and then you can use that id to associate other pieces of data with them. If you need to store grades as well, I would make that a separate "grades" table, with columns for each of the grade types, and a column to identify which grade is associated with which category.

 

Yes, the database should be able to hold a significant amount of data. I imagine you should be fine hosting it on a free test site for now, but once it becomes "official" and moves out of the testing phase, you probably should have paid hosting for it.

 

I unfortunately don't have any free tutorials to point you to, though I am sure you will find some if you Google for "free php login" or similar. I do have a tutorial on building a login system, which you can find at http://killersites.com/video-library/ within the PHP section. I have two tutorials -- one that uses standard procedural code, and the other that is MVC/OOP based (which I explain within the video, in case you aren't familiar with the terms). If you can, I'd suggest you look at the MVC/OOP one, since using OOP and MVC helps me be more efficient with coding and helps me write clean code that is easier to update in the future. The OOP/MVC course is also available here http://www.killersitesuniversity.com/courses/view/php_login_with_oop_and_mvc if you are interested in a more interactive approach other than just watching videos.

Link to comment
Share on other sites

Thanks for the reply Ben.. you are really good in scripting.

 

To be more specific: This is the OUTPUT looks like:

 

+----------------------------------+

|First Name: _____________________ |

|Last Name : _____________________ |

|Age: _____________________ |

|BirthDate: _____________________ |

+----------------------------------+

+-----+ +-----+ +-----+ +------+

|edit | |add | |del | |search|

+-----+ +-----+ +-----+ +------+

 

 

The output will just come up once someone will search some information of a specific user.

 

In relation to this, how do I associate the table's for GRADES to there Personal Information?

Lets say, someone searched for the ID "1011112"

- the Personal Information associated with the ID will come up together with the grades on the same page/same page different TAB.

 

 

I am really sorry. I am just a noob for asking this question.

@ben : It's OK if you do not have any personal TUT/Code for this project. You already helped my a lot , by giving my some ideas and advises.

 

 

------------------------------

 

I will surely watch the video that you've made. You have help a lot of programmers and programmer "wanna be" like me though this TUT.

 

 

 

More POWER TO KILLERSITES!

Link to comment
Share on other sites

To be more specific: This is the OUTPUT looks like:

OK, that's easier. It just means you use line breaks rather than the table structure. That shouldn't be complicated.

 

So, for example, instead of this:

 

// loop through results of database query, displaying them in the table
       while($row = mysql_fetch_array( $result )) {

               // echo out the contents of each row into a table
               echo "<tr>";
               echo '<td>' . $row['id'] . '</td>';
               echo '<td>' . $row['firstname'] . '</td>';
               echo '<td>' . $row['lastname'] . '</td>';
               echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
               echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
               echo "</tr>"; 
       } 

You would do

 

// loop through results of database query, displaying them in the table
       while($row = mysql_fetch_array( $result )) {

               // echo out the contents of each row
               echo 'ID: ' . $row['id'] . '<br>';
               echo 'Name: ' . $row['firstname'] . ' ' . $row['lastname'] . '<br>';
               echo '<a href="edit.php?id=' . $row['id'] . '">Edit</a> <a href="delete.php?id=' . $row['id'] . '">Delete</a>';
       } 

how do I associate the table's for GRADES to there Personal Information?

You would need to make sure that you had a column in your grades table for the user id. Then, you can get both the user's grades and information using a join: http://www.tizag.com/mysqlTutorial/mysqljoins.php

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...