我教你记得给我加分哈:1,在html页面或者php页面写一个表单,将这个页面的内容提交另外一个php页面,这个php页面是连接msq数据库的,存到数据库里面,然后你的html页面里面写查询语句代码如下:<?phpif(isset($_POST['content'])){ exit($_POST['content']);}?><form method="post"> <textarea name="content"cols="50"rows="10">内容</textarea> <input type="submit"value="提交"/></form>
<?php$con = mysql_connect("localhost","root","密码");if (!$con){die('Could not connect: ' . mysql_error());}mysql_select_db("wexeditor", $con);mysql_query("set names utf8");$result = mysql_query("SELECT name,tel,kd,dh,datetime FROM student");echo "<table border='1'>";while($row = mysql_fetch_array($result)){ echo "<tr>"; echo "<td>".$row['name']."</td>"; echo "<td>".$row['tel']."</td>"; echo "<td>".$row['kd']."</td>"; echo "<td>".$row['dh']."</td>"; echo "<td>".date("Y-m-d",$row['datetime'])."</td>"; echo "</tr>";}echo "</table>";mysql_close($con);?>这个其实就是PHP手册里的一个例子,多看看手册,对你有帮助
<?phpfunction pai( $NumStr ) { $Arr = preg_split('/[\,,]+/is', $NumStr); $Ou = $Ji = array(); foreach( $Arr as $val ) { $val % 2 == 0 ? $Ou[] = $val : $Ji[] = $val; } arsort($Ji); asort($Ou); //print_r( $Ji ); echo join(',', $Ji ), ',', join(',', $Ou );}function ca( $NumStr ) { $Arr = preg_split('/[\,,]+/is', $NumStr); echo max( $Arr ) - min( $Arr );}function length( $Num ) { echo strlen( $Num );}pai('3,6,5,71,75,34,45,23,16');echo '<br/>';ca('15,78,65,10,30');echo '<br/>';length(4578445);
恩 改了 你试试看这个我不可能写得直接能连接到你所要求的数据库的,因为不知道你数据库信息与表的设计,所以你要自己更换代码里的hostname,db_user,password,db以及表名,字段名,更换了应当就可以直接使用的,用户名密码正确与错误我做了修改<?phpsession_start(); $host = "localhost"; //服务器名称 $db_user = "root"; //用户名 $db_password = "74862856"; //密码 $db = "TEST"; //所要连接的数据库 $link_id = @ mysql_connect($host,$db_user,$db_password) or die("连接数据库失败".mysql_error()); $db_selected = mysql_select_db($db,$link_id); if(!$db_selected){ die("未找到指定的数据库".mysql_error()); } if(isset($_COOKIE['user'])){ $sql = 'select * from name where user="'.$_COOKIE['user'].'"'; $result = @ mysql_query($sql,$link_id) or die("SQL语句出错"); $row = mysql_fetch_array($result,MYSQL_ASSOC); if(isset($row)){ //如果数据库中存在该用户 Header("Location:index.php"); //合法COOKIE直接跳转到指定界面 }else{ $_COOKIE['user'] = ""; //非法COOKIE清空 Header("Location:login.php"); //重新载入界面 }}if(isset($_POST['submitted'])){ $user = $_POST['user']; $pwd = $_POST['pwd']; $sql = 'select * from name where user="'.$user.'"'; $result = @ mysql_query($sql,$link_id) or die("SQL语句出错"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $cmp_pwd = $row['password']; if($cmp_pwd == $pwd){ //用从数据库取出的密码和提交的密码比较 setcookie("user",$user,time()+300); //设置COOKIE echo "<script language=javascript>alert('登录成功');</script>"; Header("Location:index.php"); //跳转到指定页面 }else{ echo "<script language=javascript>alert('用户名或密码错误');</script>"; Header("Location:login.php"); //重新载入页面 }}?><html> <head> <title>登录窗口</title> <meta http-equiv="Content-Type" content="text/html" charset="utf8"> </head> <body> <form action="just.php" method="post"> 用户名: <input type="text" name="user" /> 密码: <input type="password" name="pwd" /> <br/> <input type="hidden" name="submitted" value="1" /> <input type="submit" value="登录" /> </form> </body></html>这个仅作参考,因为是非常简化的登录界面,没有对提交的数据进行验证,密码也不是按加密处理的,COOKIE的验证也是不安全,但整个流程的形式有了,你可以自己慢慢扩展
<table width="1008" border="0" cellspacing="0" cellpadding="0" style="margin-left:auto; margin-right:auto; margin-top:5px;border:#147FD1 1px solid;"><tr><?$i=0 foreach($Obj_huiyi as $k=>$val){?><td><?=$val['title'] ?></td><?$i++;if($i%2==0)echo "</tr><tr>"}?></tr></table>就这个原理大概就这样子了。1.用循环。内2.没两条数据换容行。
你的input type=hidden 里面的变量 $i 第一次的时候是没有值的, 如下代码e68a843231313335323631343130323136353331333238663538运行就可以了<table width="500"cellpadding="0"cellspacing="0"border="1" bgcolor="f0f0f0"> <form name="form3"method="POST"action="b3.php"> <tr> <td width="50%" height="30" align="center"valign="middle">base64</td> <td width="50%" align="center"valign="middle">base64 jiema</td> </tr> <tr> <td width="50%" align="center"valign="middle"> <input type="text"name="coding" size="20"/> </td> <td width="50%" align="center"valign="middle"> <input type="text"name="decode" size="20"/> </td> </tr> <tr> <td height="50"align="center"valign="middle">经过BASE64编码后: <?php echo"".base64_encode($_POST['coding']); $i=base64_encode($_POST['coding']); ?></td> <td align="center" valign="middle">经过BASE64解码后:<?php echo "<input type=hidden name=decode value=$i>"; echo"".base64_decode($i ? $i : $_POST['decode']); ?></td> </tr> <tr> <td height="30"colspan="2"><input type="submit"name="submit" value="提交"size="20"/></td> </tr> </form> </table>
<?php //参数Aisset($_GET['A']) ? $A = $_GET['A'] : '';//Time$time = date("Y/m/d");echo $time;//IP$ip = $_SERVER['REMOTE_ADDR'];if(!empty($_SERVER['HTTP_CLIENT_IP'])) {$ip = $_SERVER['HTTP_CLIENT_IP'];} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];}echo $ip;$db = mysql_connect('localhost', 'root', '') or die (mysql_error());//连接不上,就32313133353236313431303231363533e58685e5aeb931333332633636会显示mysql出错的原因。mysql_select_db("518", $db);$sql = "INSERT INTO TableName (Time, IP, A)VALUES ('$time','$ip','$A')";if (!mysql_query($sql,$db)) { die('Error: ' . mysql_error()); }echo "1 record added";$query = "SELECT A FROM TableName WHERE A LIKE '$A'";$result = mysql_query($query) or die("Invalid query; " .mysql_error());if (!mysql_fetch_array($result)){ echo 1;} else { echo 0;}mysql_free_result($result);mysql_close();?>
<?phpmysql_query("insert into guahao values('".$name."','".$nl."','".$shouji."','".$sname."','".$info."')");?>
判断这个变量$_SESSION['ses_group_staff_id']是否有值,如果没有,则转向login.php页面应该是判断有没有登录的代码