1 / 13

Essential PHP & MySQL Basics: Connection, Database, and Table Management

In this guide, learn key PHP and MySQL concepts essential for database management. This includes establishing a connection to MySQL by IP, username, and password, creating a database and table, inserting values, retrieving and displaying data, plus safely closing the connection. Master these foundational skills to prepare for advanced topics in MySQL. Remember, this open book exam will focus on conceptual and analytical understanding, so ensure you're well-versed in these basics.

oistin
Télécharger la présentation

Essential PHP & MySQL Basics: Connection, Database, and Table Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. End of the Php+MySQL basic part. DAY 10 Prepared by Tanvir Hamid prepared by Tanvir Hamid

  2. Things to remember • Establish the connection to Mysql by IP, username, Password • Create Database • Create Table • Insert values • Show the values • Close the connection prepared by Tanvir Hamid

  3. Connection eshtablishment Connection eshtablish <?php $con= mysql_connect("localhost",“root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } // Your code here ?> prepared by Tanvir Hamid

  4. Closing a Connection <?php $con = mysql_connect("localhost",“root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } // your code here mysql_close($con); ?> Connection close prepared by Tanvir Hamid

  5. Create Database <?php $con = mysql_connect("localhost",“root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } if (mysql_query("CREATE DATABASE tanvir",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } mysql_close($con); ?> Create the Database named tanvir See exercise 1.php prepared by Tanvir Hamid

  6. After creating database Create Table named data <?php // Create table mysql_select_db(“tanvir", $con); $sql = "CREATE TABLE data ( FirstName varchar(15), LastName varchar(15), Age int )"; // Execute query mysql_query($sql,$con); mysql_close($con); ?> See exercise 1.php prepared by Tanvir Hamid

  7. Inserting values into Table DATA <?php $con = mysql_connect("localhost",“root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db(“tanvir", $con); mysql_query("INSERT INTO data (FirstName, LastName, Age) VALUES (‘Tanvir', ‘Hamid', ‘23')"); mysql_query("INSERT INTO data (FirstName, LastName, Age) VALUES (‘Nurul', ‘Ferdous', ‘28')"); mysql_close($con); ?> See exercise 2.php prepared by Tanvir Hamid

  8. Show the values <?php $con = mysql_connect("localhost",“root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db(“tanvir", $con); $result = mysql_query("SELECT * FROM data"); while($row = mysql_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName']; echo "<br />"; } mysql_close($con); ?> See exercise 3.php prepared by Tanvir Hamid

  9. Will work details at day14(Advance MySQL) • mysql_fetch_array(), • mysql_fetch_row(), • mysql_fetch_assoc() Solve the error of your course material book & This is the HomeWork prepared by Tanvir Hamid

  10. Exam will be happened at nest class • About basic php+mySQL • About HTML, CSS • Questions will be formed ZEND style • Lecture sheet and Presentations are enough. • Open book exam prepared by Tanvir Hamid

  11. Open book exam • Remember it will be open book. • But lectures and ppt will not helping you at exam time Bcoz questions will be formed on conceptual and analytical. • NO body run the dream weaver and XAMPP or APACHE. • You will take any kinds of books, ebooks, ppt with you. prepared by Tanvir Hamid

  12. Its not joke…Exam will be Open book. prepared by Tanvir Hamid

  13. Plz turn off ur PC after finish the class prepared by Tanvir Hamid

More Related