Friday, January 24, 2014

Tute 14 : Change Html Details Page to Dyanamic Page Using php Code

Last tutorial we create a basic html details page. Now we make dynamic page details page.

Write this code top of the detailspage.php page.


---------------------------------------------------------------------------------------------
<?php
require 'connect.inc.php';
$sql="SELECT `id`, `heading`, `details`, `image` FROM tute WHERE `id`=1";
$sql_query=mysql_query($sql);
?>
---------------------------------------------------------------------------------------------
Here....
First line is : Starting php code.
Second line : include the connect.inc.php file.
Third line : Select database id, heading, details and image where id number is one.
Fourth line : query in database.
Fifth line : Ending the php code.


Now write this code in body  after the <div id="body-con-l"> code. Delate the “Left” and write this code.

---------------------------------------------------------------------------------------------
<?php
                        $query_row=mysql_fetch_assoc($sql_query);
                        $heading=$query_row['heading'];
                        $details=$query_row['details'];
                        $image=$query_row['image'];

                        echo '<h3>'.$heading.'</h3><br>';
                        echo '<img src="images/'.$image. '" class="h-img"/>';
                        echo $details;
?>
---------------------------------------------------------------------------------------------



Our “details page” page is completed.

No comments :

Post a Comment