ตัวอย่างโค้ด PHP ติดต่อ ฐานข้อมูล ของ Hosting godaddy ที่นี่ใช้ Mysql 5.0

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41410
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

ตัวอย่างโค้ด PHP ติดต่อ ฐานข้อมูล ของ Hosting godaddy ที่นี่ใช้ Mysql 5.0

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ตัวอย่างโค้ด PHP ติดต่อ ฐานข้อมูล ของ Hosting godaddy ที่นี่ใช้ Mysql 5.0

โค้ด: เลือกทั้งหมด

<?php
// ข้อมูลติดต่อฐานข้อมูล
            //ชื่อ hosting account นี้จะได้มากจาก.
            $hostname = "mindphp.db.1193340.hostedresource.com";
            $username = "mindphp";
            $dbname = "mindphp";

            //These variable values need to be changed by you before deploying
            $password = "your password";
            $usertable = "your_tablename";
            $yourfield = "your_field";
        
            //Connecting to your database
            mysql_connect($hostname, $username, $password) OR DIE ("ติดต่อฐานข้อมูลไม่ได้.");
// เลือกฐานข้อมูล
            mysql_select_db($dbname);

            //Fetching from your database table.
            $query = "SELECT * FROM $usertable";
            $result = mysql_query($query);

            if ($result) {
                while($row = mysql_fetch_array($result)) {
                    $name = $row["$yourfield"];
                    echo "Name: $name<br>";
                }
            }
?>
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 104