PHP Novice to consult database connectivity issues

Source: Internet
Author: User
Tags php and mysql
A few days ago the teacher gave a part of the code, let me connect php and MySQL, I downloaded installed a wamp, the basic page can be displayed, the database has been established and has a table, the following is the contents of config.php, how can I put the contents of the Keti1 table on the PHP page?

##################### #数据库连接 ##########################
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 ("Database connection Error! ");
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 ';

?>


Reply to discussion (solution)

I don't know what you mean, so you can tell me what you need to show.

Your database is called KETI1, where is the table called Keti1? Suppose the connection book_user table $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_ Is there a user_pass field in the user table and you go to see your watch yourself? }print_r ($pass);//The data in your User_pass field is output as an array

Thank you for replying to me yesterday, I still do not quite understand, can I send my code PHP file to you to see for me?

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.