php新手請教資料庫連接問題

來源:互聯網
上載者:User
前幾天老師給了一部分代碼,讓我把php和mysql串連起來,我下載安裝了一個wamp,基本頁面都可以顯示,資料庫已建立且有表,以下是config.php裡的內容,請問我如何能把keti1表中的內容顯示在php頁面上?

//######################資料庫連接##########################
global $hostname,$dbuser,$dbname,$dbpassword,$jiaoshi_table,$student_table,$user_table,$student_infor,$admin,$pass_admin,$teacher_name,$teacher_pass,$list_num;
$hostname="localhost";
$dbname="keti1";
$dbuser="root";
$dbpassword="";
$db=mysql_connect($hostname,$dbuser,$dbpassword) or die("資料庫連接錯誤!");
mysql_select_db($dbname,$db);
$jiaoshi_table="jiaoshi";
$student_table="student";
$student_infor="jsjxsxx";
//$user_table="book_user";
$admin="admin";
//$query="select * from $user_table where user_name='admin'";
//mysql_query("set names 'gb2312'");
//$result=mysql_query($query);
//$row=mysql_fetch_array($result);
//$pass=$row['user_pass'];
$pass_admin="bksbysj001";
$teacher_name="teacher";
$teacher_pass="bksbysj";
$list_num='30';

?>


回複討論(解決方案)

沒太懂你說的意思唉 你能把你需要顯示什麼說清楚麼

//你的資料庫叫keti1,哪裡有表叫keti1?//假設串連book_user表$query="select * from '$user_table' where user_name='admin'";mysql_query("set names 'gb2312'");$result=mysql_query($query);while($row=mysql_fetch_array($result)){$pass[]=$row['user_pass'];//book_user表中是否有user_pass欄位,你自己去看你的表?}print_r($pass);//至此你的user_pass欄位中的資料會以數組形式輸出

謝謝你昨天給我回複的,我還是不太懂,我能不能把My Codephp檔案發給你幫我看一下?

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.