mysql_connect("localhost", "kyt", "1234") or die("無法連結主機");
mysql_select_db("kkk") or die("無法連結資料庫");
$sql = "insert into pp (name, email, sex) values('蔡昆穎', 'kyt@mail.tceb.edu.tw', '男')";
mysql_query($sql) or die(mysql_error( ));
?>
mysql_connect("localhost", "kyt", "1234") or die("無法連結主機");
mysql_select_db("kkk") or die("無法連結資料庫");
$sql = mysql_query("select * from pp ");
$rows = mysql_num_rows($sql);
if($rows==""){
echo "查無資料!";
}else{
echo "有 ".$rows." 筆資料喔!";
}
?>
mysql_connect("localhost", "kyt", "1234") or die("無法連結主機");
mysql_select_db("kkk") or die("無法連結資料庫");
$sql = mysql_query("select * from pp where name='蔡昆穎'");
$pp = mysql_fetch_array($sql);
echo $pp[name]."
";
echo $pp[email]."
";
echo $pp[sex];
?>
mysql_connect("localhost", "kyt", "1234") or die("無法連結主機");
mysql_select_db("kkk") or die("無法連結資料庫");
$sql = mysql_query("select * from pp");
$rows = mysql_num_rows($sql);
for($i=0; $i<$rows; $i++){
$pp = mysql_fetch_array($sql);
echo $pp[name];
echo $pp[email];
echo $pp[sex];
echo "
";
}
?>