List the Code First: (In admin/listadmin.php)
<?php foreach ($rows as $row):?> //Note that the following foreach ($rows as $row) is followed by a colon that is not a comma <tr> <!-- Here the ID and for inside of the C1 need to loop out-- <td><input type= "checkbox" id= "C1" class= "check" ><label for= "C1" class= "label" ><?php echo $row [' id '];? ></label></td> <td>x</td> <td>x</td> <td align= "center" ><input type= "button" value= "Modify" class= "btn" ><input type= "button" value= "delete" class= "btn" ></td > </tr> <?php Endforeach?>
All users of the background administrator are listed by using the foreach () function.
And $rows is a function: (in admin/listadmin.php)
<?phpinclude '. /include.php '; $rows =getalladmin (), if (! $rows) {alertmes ("Sorry, no administrator, add!", "addadmin.php"); exit;}? >
The Getalladmin () function is: (in core/admin.inc.php)
function Getalladmin () {$sql = "Select Id,username,email from Imooc_admin"; $rows =fetchall ($sql); return $rows;}
The function of Fetchall () is: (in lib/mysql.func.php)
function Fetchall ($sql, $result _type=mysql_assoc) {$result =mysql_query ($sql), while (@ $row =mysql_fetch_array ($ result, $result _type)) {$rows []= $row;} return $rows;}
Alertmes () function: (in lib/common.func.php)
<?phpfunction alertmes ($mes, $url) {echo "<script>alert (' {$mes} ');</script>"; echo "<script> Window.location= ' {$url} ';</script> ';}? >
This is in the Learning MU lesson Network "Hand call You do e-commerce background website development" See, the teacher's code logic is really very good.
Get all the information from a list of data using foreach