Berdasarkan pengurutan

ASC/DESC

Contoh :

Tanpa tabel :

<?php
include”koneksi.php”;
$result=mysql_query(“SELECT * FROM tamu order by id desc”);
$row = mysql_fetch_array($result);
?>
<?php
echo”Nama :$row[nama]<br>”;
echo”Email : $row[email]<br>”;
echo”No Telpon : $row[notelp]<br>”;
echo”Pesan : . $row[pesan]<br> .”;
?>

Dengan tabel :

<?php
include”koneksi.php”;
$result = mysql_query(“SELECT * FROM tamu ORDER BY id DESC”);
$row = mysql_fetch_array($result);
?>
<table width=”200″ border=”0″>
<tr>
<td>nama</td>
<td>:</td>
<td><?php echo “$row[nama]”;?></td>
</tr>
<tr>
<td>email</td>
<td>:</td>
<td><?php echo “$row[email]”; ?></td>
</tr>
<tr>
<td>no telpon</td>
<td>:</td>
<td><?php echo “$row[notelp]”; ?></td>
</tr>
<tr>
<td>pesan</td>
<td>:</td>
<td><?php echo “$row[pesan]”; ?></td>
</tr>
</table>

Secara langsung /tampil semua menurunĀ 

Contoh :

Tanpa tabel :

<?php
include”koneksi.php”;
$result = mysql_query(“SELECT * FROM tamu”);

while($row = mysql_fetch_array($result))
{
echo $row[‘nama’] . ” ” . $row[’email’] . ” ” . $row[‘notelp’] . ” ” . $row[‘pesan’];
echo “<br />”;
}
?>

Dengan tabel :

<?php
include”koneksi.php”;
$result = mysql_query(“SELECT * FROM tamu”);
echo “<table border=’1′>
<tr>
<th>nama</th>
<th>email</th>
<th>telpon</th>
<th>pesan</th>
</tr>”;
while($row = mysql_fetch_array($result))
{
echo “<tr>”;
echo “<td>” . $row[‘nama’] . “</td>”;
echo “<td>” . $row[’email’] . “</td>”;
echo “<td>” . $row[‘notelp’] . “</td>”;
echo “<td>” . $row[‘pesan’] . “</td>”;
echo “</tr>”;
}
echo “</table>”;
?>

 

 

Iklan