help in separating html code and php code
Posted: Tue Jul 12, 2005 7:09 am
i'm new in using php.. guys please help meh on how to separate my php code to html... what will i do??
here's an example code,this code is combined w/ html and php..
here's an example code,this code is combined w/ html and php..
Code: Select all
<?php
session_start();
require("cn.php");
$select = "select * from $table2 where username=('$uname') and password=('$pword')";
$rs = mysql_query($select) or die(mysql_error());
$count = mysql_num_rows($rs);
if($count==1){
session_register("uname");
session_register("pword");
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<?php
if($count==1){?>
<table width="51%" height="27" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000" class="main">
<tr bgcolor="#003366" class="label1">
<td width="178"><div align="center" class="style4"><a href="<?php echo $PHP_SELF; ?>?order=name"><font color="#FFFFFF">Name</font></a></div></td>
<td width="183"><div align="center" class="style4"><a href="<?php echo $PHP_SELF; ?>?order=Message_Date"><font color="#FFFFFF">Message Date</font></a></div></td>
</tr>
<?php
if($order==""){
$order = "Msg_Id";
}
$select = "select * from $table3 order by $order";
$rs = mysql_query($select) or die(mysql_error());
$totalRows = mysql_num_rows($rs);
for($i=0;$i<$totalRows;$i++){
$rows = mysql_fetch_array($rs);
$Msg_Id = $rows["Msg_Id"];
$name = $rows["name"];
$Message = $rows["Message"];
$Message_Date = $rows["Message_Date"];
echo "<tr>
<td><a href=\"viewmsg.php?Msg_Id=$Msg_Id\"> $name </a></td>
<td>$Message_Date</td>
</tr>";
}
?>
</table>
<table width="876" height="37" border="0">
<tr>
<td height="33"><form name="form1" method="post" action="createmsg.php">
<input name="create" type="submit" id="create" value="Create Message">
</form></td>
</tr>
</table>
<p><?php }?></p>
</body>
</html>