list3_form.html
<html> <head> <title>form</title> </head> <body> <form action="list3.php" method="get"> id : <input type="text" name="id" /> <input type="submit" /> </form> </body> </html>
list3.php
<head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>list</title> </head> <body> <?php $id = htmlspecialchars($_GET['id']); $db_user = "[user name]"; $db_password = "[password]"; $db_name = "[database name]"; $db_host = "localhost"; $db = mysql_connect($db_host,$db_user,$db_password); mysql_select_db($db_name,$db); $str_sql = "select * from sa2012 where id = ".$id; $rs = mysql_query($str_sql,$db); $num = mysql_num_fields($rs); print("<table><tr><th colspan=3>list</th></tr>"); echo(" "); print("<tr>"); for ($i=0;$i<$num;$i++){ print("<td><b>".mysql_field_name($rs,$i)."</b></td>"); } print("</tr>"); while($row=mysql_fetch_array($rs)){ echo(" "); print("<tr>"); for($j=0;$j<$num;$j++){ print("<td>".$row[$j]."</td>"); } print("</tr>"); } print("</table>"); mysql_free_result($rs); mysql_close($db); ?> </body> </html>
0 件のコメント:
コメントを投稿