In my webpage i created student details in that if i click view then i want to display all student name and their details one by one but in my code i typed everything but it displays first data only.Can anyone tell me how change this code.

this my code;

echo $sql="select * from register";

Thanks in advance
Punitha pary

You should have searched daniweb solution database more thoroughly. This question has been answered a thousand times at least.
Now, once again:
There are two basic ways you can do what you need. Both ways involve a cycle - e.g. while() statement or for() statement or foreach() statement.

The difference between the two approaches is the way you manipulate with the database data.
Approach 1
1st. you have to count how many records have been returned from you sql query by counting them


2nd. You have to fetch your results this many times in the following way:

for($i=0; $i<$results; $i++)
  $row = mysql_fetch_assoc($sql1);
  echo $row['student_name'].'<br />'.$row['student_mark'];

In this way you will have all student names and student marks displayed on your page.

The other approach is the following:
1st - same as approach 1;
2nd - you load all your DB data into one array like this

for($i=0; $i<$results; $i++)
  $row[$i] = mysql_fetch_assoc($sql1);

3rd - you manipulate with the loaded array with another cycle

for($i=0; $i<count($row); $i++)
  $student = $row{$i];
  echo $student['student_name'].'<br />'.$student['student_mark'];

The output will be the same, however approach no. 2 allows you to keep the database data loaded in your variable and you can reuse this data without querying the database again.

and also use while loop like:

// display all students details