下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
<h1>Employee listing</h1> <form method="post" > <p>Enter Department ID: <input type="text" name="dept_id" size="4"> <input type="submit" name="submit" value="submit"><p> </form> <?PHP $hostname = "localhost"; $username = "root"; $password = "secret"; $database = "prod"; if (IsSet ($_POST['submit'])) { $dbh = new MysqLi($hostname,$username,$password,$database); /* check connection */ if (MysqLi_connect_errno()) { printf("Connect Failed: %s\n",MysqLi_connect_error()); exit (); } $dept_id = $_POST['dept_id']; if ($result_set = $dbh->query("call employee_list( $dept_id )")) { print ('<table border="1" width="30%"> <tr> '. '<td>Employee_id</td><td>Surname</td><td>Firstname</td></tr>'); while ($row = $result_set->fetch_object()) { printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n",$row->employee_id,$row->surname,$row->firstname); } } else { printf("<p>Error:%d (%s) %s\n",MysqLi_errno($dbh),MysqLi_sqlstate($dbh),MysqLi_error($dbh)); } print ("</table> "); $dbh->close(); } ?>
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。