关于php中利用sql语句创建表的问题
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php$con=mysql_connect("localhost","root","");if($con){ mysql_select_db("text",$con); mysql_query("set name gtf8"); $sql="create table user_date ( id int(5) not null auto_increment primary key, name char(10) not null default '', password char(12) not null default '', age int(3) not null default 0, sex char(10) not null default 'man', mail char(50) not null default '', qq char(10) not null default '', gedree char(10) not null default '', fav char(50) not null default '' )"; $do=mysql_query($sql,$con); if($do) { echo "create user data successful!!"; } else echo "create error!!!!!";}else { echo "connect error!!!!";}?><!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phpecho "<style type=\"text/css\"><!--body {color:#000099;font-size:10pt; text-align:center}--></style>";if($_POST){ $user=$_POST["user"]; $pass=$_POST["pass"]; $age=$_POST["age"]; $sex=$_POST["sex"]; $mail=$_POST["mail"]; $qq=$_POST["qq"]; $degree=$_POST["degree"]; $fav=$_POST["fav"]; $len=count($fav); $fav_z=""; for($i=0;$i<$len;$i++) { $fav_z=$fav_z.$fav[$i]; if($i<$len-1) $fav_z=$fav_z.","; } $con=mysql_connect("localhost","root",""); mysql_select_db("ceshi"); mysql_query("set names GB2312"); $sql="select count(*) from user2 where name='$user'"; $result=mysql_query($sql); $num=mysql_fetch_row($result); if($num[0]>0) { echo "have the same name!try another one."; } else { $sql="insert into user2(name,password,age,sex,mail,qq,degree,fav)value('$user','$pass','$age','$sex','$mail',$qq','$degree','$fav_z')"; $re=mysql_query($sql); if($re) echo "insert successful!"; else echo "insert error~!"; echo "<p>"; }}else { echo "nothing upload!<br>";}echo "<br>click<a href='reg.html'>there</a> return";?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号