php code for fetching data from database

<?php
  ////////////neha jaiswal///
$serve="localhost";
$user="root";
$password="";
$db="neha";
$con=mysqli_connect($serve,$user,$password,$db);
 if ($con) {
 echo "connection success"; 
 }else
{echo "connection unsuccess"; }
 $query="SELECT * FROM product";
 $result=$con->query($query);
 if($result->num_rows>0){
 	while($row=$result->fetch_assoc())
 	{
 		echo $name=$row['name'];
 		echo $qty=$row['qty'];
 		echo	$price=$row['price'];
 		echo	$image=$row['image'];
 	}
 }

?>

4.17
6
Phoenix Logan 186120 points

                                    
CREATE DATABASE company;
CREATE TABLE employee(
employee_id int(10) NOT NULL AUTO_INCREMENT,
employee_name varchar(255) NOT NULL,
employee_email varchar(255) NOT NULL,
employee_contact varchar(255) NOT NULL,
employee_address varchar(255) NOT NULL,
PRIMARY KEY (employee_id)
)
Copy

4.17 (6 Votes)
0
0
0
Krish 100200 points

                                    
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Read Data From Database Using PHP - Demo Preview&lt;/title&gt;
&lt;meta content=&quot;noindex, nofollow&quot; name=&quot;robots&quot;&gt;
&lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;maindiv&quot;&gt;
&lt;div class=&quot;divA&quot;&gt;
&lt;div class=&quot;title&quot;&gt;
&lt;h2&gt;Read Data Using PHP&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&quot;divB&quot;&gt;
&lt;div class=&quot;divD&quot;&gt;
&lt;p&gt;Click On Menu&lt;/p&gt;
&lt;?php
$connection = mysql_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;&quot;); // Establishing Connection with Server
$db = mysql_select_db(&quot;company&quot;, $connection); // Selecting Database
//MySQL Query to read data
$query = mysql_query(&quot;select * from employee&quot;, $connection);
while ($row = mysql_fetch_array($query)) {
echo &quot;&lt;b&gt;&lt;a href=&quot;readphp.php?id={$row['employee_id']}&quot;&gt;{$row['employee_name']}&lt;/a&gt;&lt;/b&gt;&quot;;
echo &quot;&lt;br /&gt;&quot;;
}
?&gt;
&lt;/div&gt;
&lt;?php
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query1 = mysql_query(&quot;select * from employee where employee_id=$id&quot;, $connection);
while ($row1 = mysql_fetch_array($query1)) {
?&gt;
&lt;div class=&quot;form&quot;&gt;
&lt;h2&gt;---Details---&lt;/h2&gt;
&lt;!-- Displaying Data Read From Database --&gt;
&lt;span&gt;Name:&lt;/span&gt; &lt;?php echo $row1['employee_name']; ?&gt;
&lt;span&gt;E-mail:&lt;/span&gt; &lt;?php echo $row1['employee_email']; ?&gt;
&lt;span&gt;Contact No:&lt;/span&gt; &lt;?php echo $row1['employee_contact']; ?&gt;
&lt;span&gt;Address:&lt;/span&gt; &lt;?php echo $row1['employee_address']; ?&gt;
&lt;/div&gt;
&lt;?php
}
}
?&gt;
&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;?php
mysql_close($connection); // Closing Connection with Server
?&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy

0
0
0
0
Phoenix Logan 186120 points

                                      &lt;?php
   //////neha jaiswal////
       include 'config.php';////incluude data base connection file
        $stmt = $conn-&gt;prepare('SELECT * FROM `product`');///select all data from database
        $stmt-&gt;execute();////query execute ($stmt)
        $result = $stmt-&gt;get_result();
        while ($row = $result-&gt;fetch_assoc()):
      ?&gt;
         &lt;div class=&quot;card p-2 border-secondary mb-2&quot;&gt;
            &lt;img src=&quot;&lt;?= $row['product_image'] ?&gt;&quot; class=&quot;card-img-top&quot; height=&quot;250&quot;&gt;
            &lt;div class=&quot;card-body p-1&quot;&gt;
              &lt;h4 class=&quot;card-title text-center text-info&quot;&gt;&lt;?= $row['product_name'] ?&gt;&lt;/h4&gt;
              &lt;h5 class=&quot;card-text text-center text-danger&quot;&gt;&lt;i class=&quot;fas fa-rupee-sign&quot;&gt;&lt;/i&gt;&lt;?= number_format($row['product_price'],2) ?&gt;/-&lt;/h5&gt;

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to get data in php from database fetch array from database in php fetch value from mysql php fetch data using functions in php fetching data from mysql using php php code to fetch data from database fetch data from database in php with javascript how to fetch data from database in drop down list php how to fetch data from a table in mysql and php how to fetch data from database in table format in php fetch data from the database in php fetch data form database php use of fetch in php fetch data from api using php fetch data using php fetch data from database in php and display html table how to access data fetch from database to variable in php fetch result in php fetching data in php how to fetch data from mysql in php how not to fetch all data in php fetch sql results php write the php code for fetching the data from a database to a web page fetch from databse php getting data inside fetch in php fetch array data from database in php fetching the data from database using api url in php fetch all data php how to get data from db php fetch data from table in php how to get data for database using php php how to fetch data from database products with whi php how to fetch data from database fetch a database value as oop php fetch from db of particular user and display in table php how to get data from database to php how to get data from a database in php php fetch all from db add php value in fetched data from database fetch data from sql in core php fetch data php from page how fetch data from database in php fetch data php url fetch data functions.php when click on a button it fetch a data from database using php and mysql how to get the data from database in php php fetch db fetch all data in a table using php js fetch php data data fetch from database in php fetch all database info as a table using php method get data from database php fetch database data in php how to fetch values in php How to fetch data from database in PHP and display in html table using PDO fetch class fetch data from SQL data base using PHP fetch data php how to fetch div from database in php how to fetch from database in php fetching data from database in php how to fetch input data from database using php and display how to fetch input data from database using php php get data from db fetch database value in php php connect to mysql and fetch data all to fetch all data from database in php code for fetching data from database in php how to fetch data from database in php and display html tables how to fetch data in array from database in php how fetch data from database in php using ajax how to fetch data from database using mysql in php how to get data in database in php how to fetch data in php php program to fetch data from database How can I use fetch() to get data from a PHP file? how to fetch data from database and load on page with php php not fetching data from database how to get data from database with php how to show xxx while fetch data from database php fetch and return data php how to display the database fetch data using ajax in php how to retrieve data from a database in php data fetch from db in core php php getting data from database how to fetch database data in php fetching database in php php function to fetch data from database how to fetch data from database in php and display in html div how to fetch data from database in oop php how to fetch specific data from database in php php fetch value from database get php data with fetch js get php data with fetch php fetch data from database fetch data from database in php and display html fetch items from db php fetch api data in php In PHP, we can fetch data from database using _________________ function fetch data by execute php odbc how to fetch data in php data fetch from database in php with procedure fetching feeds with PHP fetch data from database in selct option php php fetch all data php mysql fetch result fetch mysql data in php php how to get data from a database function in php to fetch all the data from the databse how retrieve data from database in php latest php code to fetch data from database fetch data from mysql in php fetch code in php fetch data from database in php json $result = fetch_data(); php how to fetch data from a database in php how to fetch data from database in php using primary key How to fetch data from database using datatable in PHP fetching data from mysql php fetch data from mysql php sql fetch example php fetch data from database to html php how to fetch the value from mysql database using php fetch data from api and show in table using php how to use select tag to fetch data from database in php fetch data from db in php and display array live fetch data from database using fetch api in php and render to html fetch data from database using fetch api in php and render to html fetch sql php php get database data php fetch data from mysql and show in html how to use php to post fetch data from database how to fetch data from database using json in php How to fetch single value from database in PHP php sql fetch fetch data from database php php fetch data from mysql How to Fetch Data From Database in PHP And Display php database get data function fetches the value from database php how to fetch data from database from php to java fetch rows from db in php how to fetch data in select option value get through database in php fetch data from mssql in php fetch data from msql in php How to fetch data from database in PHP using MVC how to fetch the data frm database in mvc php fetch data from api php get data from db in php mvc php mysql project for fetching the data php code to get data from database how to fetch selected data from database in php why query is not fetching data from database in php how get data from database in php how to fetch data as it added in php fetch connection php php fetch data from table php fetch record from database prepare statement to fetch data in php How to fetch data from database and store in variable in PHP how to fetch data from database in select box in php php mysql fetch data Fetch all data from database where in PHP Fetch all data from database in PHP how to fetch data from database in php and display in select option php fetch from database read item in sql in php fetch fetch data from database using php in option tag fetch data in database php get data from db using fetch js php how to fetch data by query in php how to fetch data from database in php and display in html table how to fetch data from database in php and display in table student tutorial how to fetch data from database and show in table in php fetch all with while php how to fetch data from mysql in php using id how to fetch data from database in php and display in output student tutorial how to fetch data from database in php and display in output How to fetch data from database in PHP and display in div get data from fetch php get data from fetch response php how to fetch data from database in php and display in table proper function in php fetch all data from sql how to fetch data from database in php and display back to the form php get data from database How to fetch data from database in PHP using search button tutorial store fetch results in php odbc how to fetch data from db in php how to get data from the database in php how to get data from a db php how to fetch and display data from database in php mysql fetch php ways to fetch data from MySQL with PHP fetch database value in table in php get data from database using php fetch all records from database in php select option in the php use fetch data from database fetch data from database in php for select box fetch data from database with pure javascript and php fetching data from database using php fetch single value from database in php fetch value from database in php how to fetch database value in php how to fetch name from database in php php code for fetching data from database fetch table data in php how to retrieve data from database in php get data from db php how can i fetch data from php how to retrieve data from database using php fetch data from database in php and display html tables fetch data from database in php php fetch data from db to select option fetch data in table php fetch data in php php data fetch from database php fetch data how to get data from database using php how to get data from database in php php program to connect to the database and extract data from the table php mysqli_query select example how to search and fetch data from database in php how to fetch data from database in php using get method result database php extract data from sql database using php php get value from database table display all records in table php get data from database in php a simple php mysql script that retrieves data from database php mysql view data query for retrieving data from database table through id how to retrieve data from database in php using mysql php mysqli which data is selected select data php mysql select a value from database php query sql from php feching data from database Fetching data from MySQL database using PHP get data with key in php mysql db get data with key php mysql mysql select table php get data from mysql to html how to get data from database php php query select and fetch data display data from sql database php how do you call a data from database php how to get data from database table in php get data from database php how to get database data in php display data in php from database how to view data in mysql using php from html form php mysql select where using id form get data database get data from data base data in php select table php how to retrieve value in core php fetch send data to php fetch array from database php how to fetch data from api in php select all rows mysql php www-data mysql and php while get data mysql how to display data from database in php in table w3schools how to fetch data from database in php
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source