Connecting to MySQL using in PHP
This example connects to the database blogger at the address 127.0.0.1(or you can type localhost instead) with the user admin and the password abcdefg. Then issues a query to select all rows in the table blog_posts, and prints the field value of title and post of each row. Lastly, it closes the database connection.
<?php $con=mysqli_connect("127.0.0.1","admin","abcdefg","blogger"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM blog_posts"); while($row = mysqli_fetch_array($result)) { echo $row['title'] . " " . $row['post']; echo "<br>"; } mysqli_close($con);
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts