Hi J,
OK, what you're code is doing is:
- running the query on your database
( $result1=mysql_query("SELECT * FROM tbllevel1 "); )
- reading the first row of the data into an associative array:
( $row = mysql_fetch_assoc($result1); )
- running a loop, that will start with the second row from the data you got back, reading each row into an associative array and printing the ['Level1'] field:
( <?php do { ?>
<? echo $row['Level1'];?><br>
<?php } while ($row = mysql_fetch_assoc($result1)); ?> )
- trying to run the same loop again, but you've now reached the end of your data, so the initial while condition would never evaluate as true, so it's executed once with no data.
BTW, You don't need the <?php for each statement, just use it to start and finish blocks of php.
Try something like:
<html>
<head></head>
<body>
<?php
include("connection/connection.php");
connect_init();
$result1=mysql_query("SELECT * FROM tbllevel1 ");
echo mysql_error();
// it's better to use a while statment, than a do-while,
// just in case you don't get any data back
while($row = mysql_fetch_assoc($result1)) {
// this 'pushes' your field onto an array
$my_array[]=$row['Level1'];
}
// at this point the array $my_array contains each value of
//the field 'Level1' from each row in the table
?>
<table width="100%">
<?php
// this foreach loop is going to go through each element in our array,
// and print 1 table row, with 2 cells, each containing the datat from
// the field "Level1"
foreach ($my_array as $_) {
echo "<tr> <td>";
echo $_;
echo "</td> <td>";
echo $_;
echo "</td> </tr>";
}
?>
</table>
Bear in mind that this is untested and I'm really a perl programmer, but it'll hopefully get u started :-)
Charlie
--
Don't Stand on your head - you'll get footprints in your hair
http://charlieharvey.org.uk
http://charlieharvey.com