Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MySQLÊý¾Ý¿â¹ØÁªµÄÎÊÌâ

ÎÒ½¨ÁËÁ½¸ö±í£¬Ò»¸ö±íÃ÷user£¬Ò»¸ö±íanswer
±íuserµÄ½á¹¹{id,username,password}
±íanswerµÄ½á¹¹{A_id,question,answer,U_id}
Çë½Ì´ó¼ÒÎÒÔõôÉèÖòÅÄÜÔÚ±íuser²åÈëÊý¾Ýʱ£¬±íanswer¶ÔÓ¦µÄU_id×Ô¶¯¸üжÔÓ¦±íuserµÄid ¡£
ÄÇλ´óÏÀ£¬¸øдÏ´úÂë¿ÉÒÔÂ𣿣¿£¿
Èç¹ûÓÃPHPºÜÈÝÒ×½â¾ö£¬
Èç¹ûÓÃMYSQL¿ÉÒÔÓô¥·¢Æ÷½â¾ö£¡

1Â¥µÄ£¬Äã¿ÉÒÔ°ÑÁ½ÖÖ·½·¨¸ø˵Ã÷ÏÂÂ𣿣¿£¿

²»Ì«Ã÷°×ÄãµÄÒâ˼?Ϊʲôuser±íÌí¼ÓÊý¾Ýanswer±í¾ÍÒª¸üУ¿ÄãÏ£ÍûÔõÑù¸üУ¿¸üеÄÌõ¼þÊÇʲô£¿

ÎÒµÄÊý¾Ý±íanswerµÄU_id¶ÔÓ¦µÄÊDZíuserµÄid£¬ÎÒÔÚ²åÈëÊý¾Ýʱ£¬±íuserµÄid×Ô¶¯²åÈëÊý×Ö£¬ÎÒÏëÈñíanswerµÄU_id£¬Ò²×Ô¶¯²åÈëÊý×Ö£¬µ«²åÈëµÄÊý×Ö£¬ÒªºÍ±íuserµÄidµÄÊý×Ö±£³ÖÒ»ÖÂÐÔ£¬Á½¸öÊý×ÖÒªÒ»Ñù¡£¡£¡£

PHP·½·¨£º
PHP code:

$u="insert user values('','$name','$psw')";
$rs=mysql_query($u);
$id=mysql_insert_id();
$a="insert into answer values('','$question','$answer','$id')";
mysql_query($a);


mysql´¥·¢Æ÷£º
SQL code:

mysql> delimiter |
mysql> create trigger insertanswer
-> before insert on user
-> for each row begin
-> insert into answer values('','','','new.id');
-> end;
-> |



[code={php}]
{$sql= "INSERT INTO user (id,username,password)VALUES('',


Ïà¹ØÎÊ´ð£º

PHP °ÑwordÎĵµÄÚÈݵ¼ÈëmysqlÊý¾Ý¿â

ÎҼǵÃÔÚmysqlÖÐÓиöload data infile Óï¾ä¿ÉÒÔ°ÑwordÎĵµµÄÄÚÈÝ°´Ò»¶¨¸ñʽµ¼ÈëÊý¾Ý¿â£¬ÕâÑùµ¼ÈëµÄÊý¾ÝÀàÐͺÃÏñÖ»ÄÜÊÇÎı¾¸ñʽµÄÊý¾Ý£¬ÇëÎÊÓÐû¸üºÃµÄ·½·¨¿ÉÒÔµ¼ÈëÊý¾Ý¿â¡£

1¡£Èç¹ûÎÒÃÇÒª°ÑÊÔÌâµ¼ÈëÌâ¿â£¬ÄÇà ......

ÇëÎÊphpÅäºÏmysqlÔõôµÃ³öÈ«²¿Èí¼þÈÝÁ¿µÄºÍ£¿


mysql±È½Ï²Ë£¬
×Ö¶ÎÀïÃæÓиö MB ,²»ÊÇÊýÖµÐÍ£¬ÆäËüÓÐЩ¡°Î´Öª¡±£¬Ôõô²ÅÄܵóö×îÖÕÏà¼ÓµÄ½á¹û£¿
SQL code:

mysql> select * from t;
+----------+
| size |
+----------+
| 0.47 MB |
| NU ......

JSP Á¬½ÓMysql Ò»Ö±Á¬½Ó²»ÉÏ

ÎÒÓõÄÊÇeclipse-jee-galileo-SR1-win32 tomca6.0 Mysql5.1 ÏÂÔØÏÂÀ´µÄÇý¶¯ÊÇmysql-connector-java-5.1.10-bin.jar ÎÒ½«Ëü·ÅÔÚÁËD:\Ŀ¼Ï²¢Ð´½øÁËϵͳ±äÁ¿calsspath »¹°ÑËü·Å½øÁËeclipse¹¤×÷ÇøµÄ ÏîÄ¿\WebContent\W ......

jspÁ¬½ÓmysqlÊý¾Ý¿â²éѯ£¬²¢ÔÚÒ³ÃæÏÔʾ

jspÁ¬½ÓmysqlÊý¾Ý¿â²éѯ£¬²¢ÔÚÒ³ÃæÏÔʾ Öм䲻ÓÃstruts£¬ÔõôʵÏÖ£¬ÇóÀý×Ó

javabean ×öÁ¬½Ó
jsp Ò³ÃæʵÀý»¯Àà
jsp Ò³ÃæÏÔʾÊý¾Ý
<%@ page contentType="text/html;
charset=gb2312" ......

100·ÖÇóÖú£¬¹ØÓÚJSPÏÂÌá½»ÖÐÎÄ×Ö·ûÈ¥MYSQLÂÒÂëÎÊÌâ¡£

jspÌá½»Ò³±àÂëÊÇUTF-8£¬MYSQL¿âÒ²ÊÇUTF-8,ΪʲôÌá½»ÁËÖÐÎÄ×Ö·ûÔÚÊý¾Ý¿âÀï±ä³ÉÂÒÂëÁËÄØ£¿

ÕâÖÖÎÊÌâÔõô½â¾ö£¿Ð»Ð»

ÁíÍ⣬JSPµ¯³ö¶Ô»°¿ò£¨±ÈÈ絯³ö¡°XXXÉóºËͨ¹ý¡±ÏÂÃæ¸úÈ·¶¨°´Å¥£©ºÍ·µ»ØÉÏÒ»Ò³ÒÔ¼°×ªµ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ