HI friends hope you are familiar with the previous portions. Now we are continuing our explanation of code from learning 7.

I’m skipping the html codes. and we are directly going to line number 28.

1
<a href="Registration.php" style="text-decoration:none; font-size:24px;">Resistration</a>

This line of code used to redirect to the registration form.This is known as anchor tag.In href portion we give our page to which we want to be redirected.

Now we are going to line number 43.’$i = 1′. which is the initialisation of variable ‘$i’.Which is used to print the serial numbers to the records that is 1,2,3,4 etc.

The very next line we are extracting the result we get from database using object.

1
while($row=mysql_fetch_array($res)){?>

There are some other ways also there to extract the result. Please have a look below things to know about it.

  • mysql_fetch_array()
  • mysql_fetch_object()
  • mysql_fetch_row()

mysql_fetch_array() – Fetch a result row as a combination of associative array and regular array.
mysql_fetch_object() – Fetch a result row as an object.
mysql_fetch_row() – Fetch a result set as a regular array().
The difference between mysql_fetch_row() and mysql_fetch_array() is that the first returns the results in a numeric array ($row[0], $row[1], etc.), while the latter returns a the results an array containing both numeric and associative keys ($row[‘name’], $row[’email’], etc.). mysql_fetch_object() returns an object ($row->name, $row->email, etc.).

Hope it is clear to you. for more understanding do it with your own examples. if you have any query about it please free to ask me

We get each row of result int he array variable ‘$row’ and we can access each value by its name saved in the data base or the name specified in the query. for example,

1
<?php echo $row['vchr_name']; ?>

Here we get the name of the student saved in the data base using the field name ‘vchr_name’. Like this we can access all the other fields like this. Please look at line number 49 before we winding up this article here we used an anchor tag. Can you guess for what it is used?. Yes on clicking the student name we are redirected to the edit page (For editing the details of that particular student).This is all for now. if you have any doubt please ask.

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *

37 − 33 =