Full Post Page

Latest Full Posts

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: Ready to kickstart your coding journey? Subscribe to [Rupesh-Tech] on YouTube and start learning today! Don't forget to hit the bell icon to receive notifications whenever we upload new tutorials or go live with Q&A sessions. Remember, coding opens up a world of endless possibilities. Whether you're dreaming of becoming a software developer, launching your own startup, or simply exploring a new hobby, [Rupesh-Tech] is here to help you turn your coding aspirations into reality. Let's code together and unleash your full potential! Feel free to customize the content to better suit Rupesh-tech channel's branding and audience.



Recent Posts

IMAGE CRUD PHP MYSQL

September-04-2024 09:18:37


complete php project mysql

August-11-2024 11:31:12


LARAVEL 11 crud step by step

August-02-2024 23:22:25