Full Post Page
 

OOP CONNECTION MYSQLI SHOW IN UL TAG AND TABLE

Category: PHP PROGRAMING & Written by Admin On April-04-2024 08:35:42

@@@@@@@@@@@@@@@@@ connection @@@@@@@@@@@@@@@ <?php $servername= "localhost"; $username="root"; $password="";$dbname="test"; $conn= new mysqli($servername,$username,$password,$dbname); if($conn->connect_error){ die("connection failed:" .$conn->connect_error); } @@@@@@@@@@ Fetch data @@@@@@@@@@@@@ $sql = "SELECT *FROM contacts"; $result= $conn->query($sql); if($result->num_rows >0){ while($row= $result->fetch_assoc()){ // echo '<pre>'; // echo "contacts_id:{$row["contacts_id"]} -Name:{$row["contacts_name"]} -Email:{$row["contacts_email"]} -Message{$row["contacts_message"]} \n"; // echo '</pre>'; echo '<ul>'; echo "<li> contacts_id:{$row["contacts_id"]}</li> <li>-Name:{$row["contacts_name"]}</li><li> -Email:{$row["contacts_email"]}</li> <li>-Message{$row["contacts_message"]}</li> \n"; echo '</ul>'; } }else{ echo "No results Found"; } <?php @@@@@@@@@@@@@@ SHOW IN TABLE @@@@@@@@@@@@@@@@@ $sql = "SELECT *FROM contacts"; $result= $conn->query($sql);?> <table border="1" cellspacing="2" cellpadding="3" width="100%"> <thead> <tr> <th> Id:</th> <th>Name: </th> <th> Email:</th> <th>Message:</th></tr> </thead> <tbody> <?php if($result->num_rows >0){ while($row= $result->fetch_assoc()){ echo "<tr style='text-align:center'> <td align:center>{$row["contacts_id"]} </td> <td style='text-align:center' >{$row["contacts_name"]}</td> <td>{$row["contacts_email"]}</td> <td>{$row["contacts_message"]}</td> </tr>"; } }else{ echo "No results Found"; } $conn->close(); ?> </tbody></table>

Comments

Share your thoughts about this post

Why Choose Us:

Experienced Instructors: Our team of experienced instructors are passionate about coding and dedicated to helping you succeed. With years of industry experience and a knack for teaching, they'll guide you every step of the way. Beginner-Friendly Content: Don't worry if you're new to coding. Our tutorials are designed with beginners in mind, starting from the fundamentals and gradually building up to more advanced topics. Updated Content: Coding is a rapidly evolving field, and we're committed to keeping our content up-to-date with the latest trends, technologies, and best practices. Community Support: Learning to code is more fun and effective when you're part of a supportive community. Join our online community forums to connect with fellow learners, share insights, and collaborate on projects. Get Started Today:



Recent Posts

Advance Js Fetch API Part-5

June-06-2025 21:23:08


Advance Js Promise Part-4

June-06-2025 11:35:05


Advance js oop part-3

June-06-2025 08:25:42


ExpressJs API With Image Crud-3

June-02-2025 21:09:41


NodeJs API-MVC-2

June-02-2025 10:56:22


ExpressJs API Crud-1

June-02-2025 10:27:58


ExpressJs Files upload

June-02-2025 10:15:40


NodeJS Cookie and CsrfToken

May-30-2025 19:20:40


ExpressJS Session

May-30-2025 19:14:29


ExpressJS NodeJs Crud Part-2

May-27-2025 21:52:18


ExpressJS NodeJS Crud Part-1

May-27-2025 21:33:30


ExpressJS Authentication

May-26-2025 17:11:41


NodeJS ExpressJS Files Upload

May-26-2025 16:53:29



Angular Introduction

May-13-2025 21:02:32



Advance Js part-1

May-12-2025 15:41:29