Looking For Anything Specific?

Dyanmic Report in PHP

Dynamic report in PHP

  • ·         Suppose you have only the name of the database and table, you don’t know the field name of your table and you want to fetch the data from the table.

  • ·         In this situation we are going to teach how to fetch data from database.

  • ·         Open your favorite text editor and type following code.

  • ·         Here I have database name cat and table name product.

  • ·         But I don’t know the field name of product table.

            $con=mysql_connect("localhost","root","") or die("can't connect");
            $qu=mysql_query("select * from product");       //query to product table.
            $c=mysql_num_fields($qu);      // This function return the number of row in your table.
            echo "<table border=1><tr>";
            echo "<td>".mysql_field_name($qu,$i)."</td>"; //This function return the name of rows
            echo '</tr>';
                        echo "<tr>";                
            echo "<td>".$row[mysql_field_name($qu,$i)]."</td>"; //Here we are display it

                        echo '</tr>';
            echo "</table>";

  • ·         Save this file as index.php and run it.

  • ·          It will look like this.
  • ·         Our dynamic report in php will now over here have fun with PHP.