<?php
/
数组:在一个变量中,存储一个或多个值,每一个元素都有一个访问ID
foreach($arr as $key=>$value)
/
$arr = array('李海','PHP视频教程','29','1982-05-08');
//print_r($arr);
//echo "学员名是:".$arr[0]." 所学课程:".$arr[1]." 年龄:".$arr[2]." 生日:".$arr[3];
$arr1 = array("uname"=>"江梅","uclass"=>"DIV+CSS","age"=>"44","birth"=>"1958-08-11");
//print_r($arr1);
//echo "年龄:".$arr1['age']."出生日期:".$arr1['birth'];
$arr2 = array(array("uname"=>"李满","age"=>"15"),array("uname"=>"小海","age"=>"38"));
echo "<pre>";
//print_r($arr2);
//echo $arr2[1]["uname"];
$arr3["网站名称"]="后盾网";
$arr3["课程"]="php教程";
$arr3["课时"]="300课时";
//print_r($arr3);
$arr4[]="PHP课程";
$arr4[]="网站标准布局课程";
//print_r($arr4);
$arr5["PHP"]=array();
$arr5["PHP"]['cname']="php课程";
$arr5["PHP"]['ctime']="300课时";
$arr5["DIV"]=array();
$arr5["DIV"]['cname']="DIV+CSS课程";
$arr5["DIV"]['ctime']="100课时";
$arr5['HTML']="HTML基础知识如TABLE,IFRAME课程";
$arr5['JAVASCRIPT']="js知识,jqery课程";
//print_r($arr5);
/*
foreach($arr3 as $k=>$value){
if($k == "课程"){
echo $k. "<span style='color:#f00; border:solid 1px #ccc; padding:2px; width:200px;'>".$value."</span>";
}else{
echo $k.$value;
}
}
/
/
foreach($arr5 as $key => $value){
echo "<div style='border:solid 1px #582553;margin-bottom:6px;font-size:14px;'>";
if(is_array($value)){
echo $key.":
";
foreach($value as $k=>$v){
echo " <span style='font-size:12px;'>".$k."=>".$v."</span>";
}
}else{
echo $key."=>".$value;
}
echo "</div>";
}
/
/
foreach($arr5 as $key => $value){
echo "<div style='border:solid 1px #582553;margin-bottom:6px;font-size:14px;'>";
if(is_array($value)){
echo $key.":
";
echo "课程名:".$value['cname']." 课时:".$value['ctime'];
}else{
echo $key."=>".$value;
}
echo "</div>";
}
/
$db = new mysqli('localhost','root','123456','edu') or die('连接错误');
$db->query("set names gbk");
$sql ="select from user";
$result = $db->query($sql);
echo "<table border=1>";
while($row = $result->fetch_assoc()){
echo "<tr>";
echo "<td>学员名:</td><td><b>{$row['uname']}</b></td><td>课程名:{$row['cname']}</td>";
echo "</tr>";
}
echo "</table>";
共同学习,写下你的评论
评论加载中...
作者其他优质文章