• Streams & Subjects

    Streams & Subjects

    Get detailed description of each and every topic with proper examples including text, images and videos.

  • Latest Technologies

    Latest Technologies

    Know more about the latest and new emerging technologies and boost your knowledge.

  • Programming

    Programming

    Don't learn just codes and syntax, instead learn the best and efficient way of coding.

  • Technologies

    New Technologies

    Get instant and relevant updates of the latest emerging technologies of lots of streams including web, clouds, virtualization, etc.

  • Freewares

    Freewares

    Download free trials and freewares of various fields and check out their efficiency before buying.

  • Multimedia

    Multimedia

    Learn techniques to design amazing and creative multimedia designs and characters including 2D & 3D layout with rendering.

Showing posts with label PHP Tutorial. Show all posts
Showing posts with label PHP Tutorial. Show all posts

Select query in php

From the select query in php we are going to select entire or extract data from the table. We are using mysql_query() to retrieve the data. Here example for goes to get data from database.


<?php
          $conn=mysql_connect("localhost","root","");
          $sel=mysql_select_db("proj",$conn);
          $c = mysql_query("select * from data");
          echo "<table border='1'>";
          echo "<tr><td>name</td><td>Last name</td><td>Address</td><td>Email id</td><td>Phone</td></tr>";
          while($row = mysql_fetch_array($c))
          {
                   echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td></tr>";
          }
          echo "</table>";
?>

Output:



Read more

Update query in php



Update data from Php:

In this tutorial we are show the table value can be update from old one to new one.In this example name in the field value henry will changed to the mathavan

Syntax:

update table_name set attri_name='value' where attr_value='value to be changed'


this syntax for update value in table


<?php
            $conn=mysql_connect("localhost","root","");
            $sel=mysql_select_db("proj",$conn);
            $c = mysql_query("select * from data");
            echo "<table border='1'>";
            echo "<tr><td>name</td><td>Last name</td><td>Address</td><td>Email id</td> <td>Phone</td></tr>";
            while($fetch = mysql_fetch_array($c))
            {
                        echo "<tr><td>$fetch[0]</td><td>$fetch[1]</td><td>$fetch[2]</td><td>$fetch[3]</td><td>$fetch[4]</td></tr>";
            }
            echo "</table>";
            $q=mysql_query("update data set name='mathavan' where name='kenry'");
            if($q)
            {
                        echo"update";
            }
            $c = mysql_query("select *from data");
            echo "after updating";
            echo "<table border='1'>";
            echo "<tr><td>name</td><td>Last name</td><td>Address</td><td>Email id</td><td>Phone</td></tr>";
            while($row = mysql_fetch_array($c))
            {
                        echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td></tr>";
            }
            echo "</table>";
?>



Output:


Read more