Search This Blog

Friday, 29 December 2017

how to mix php in html

When I use iframe in HTML file that linked to test.php .. the result is OK
Test.php :
<?php     
   $host = "localhost";
   $user = "user";
   $pass = "pass";
   $database = "db";
   $koneksi = mysql_connect ($host,$user,$pass);

   mysql_select_db($database,$koneksi) or die ("error");

   $result = mysql_query("SELECT * FROM pengumuman"); 
   $i = 0;

   while($row = mysql_fetch_array($result)) { 
        echo "<li><a href='#'>".$row['judul']."</a></li>";
        $i++;
   } 

   mysql_close($koneksi); 
?>
But I do want to separate this test.php, so I mixed it in my HTML file
<?php 
   $host = "localhost";
   $user = "user";
   $pass = "pass";
   $database = "db";
   $koneksi = mysql_connect ($host,$user,$pass);

   mysql_select_db($database,$koneksi) or die ("error");

   $result = mysql_query("SELECT * FROM pengumuman"); 
   $i = 0;

   while($row = mysql_fetch_array($result)) { 
?> 
   <li><a href='#'><?php $row['judul'] ?> </a></li>

<?php 
        $i++;
   }   
    mysql_close($koneksi); 
?>

0 comments:

Post a Comment