0
我需要你的一些幫助:)...當我們選擇組合框中的'信息'列表時,自動出現類型爲「信息」特徵的文章,當我們在組合框中選擇'Berita'列表時,與類型'Berita'特性出現..這裏是我的代碼...它是一個長腳本TT &它使用post方法..你能幫我使它有點簡單嗎?使用功能也許。由於之前用組合框排序?
<form method="post" name="form2">
<select name="type" id="type">
<option value="Semua">Semua</option>
<option value="Berita">Berita</option>
<option value="Info">Info</option>
</select>
<input type="submit" id="type" />
</form>
<table width="200" border="1" class="tbl_art_content" id="results">
<tbody>
<tr>
</tr>
<?php
$i=0;
$no=0;
if($_POST['type'] == 'Semua')
{
$query_art = mysql_query("SELECT * FROM artikel_tbl ORDER BY id") or die(mysql_error());
}
else if ($_POST['type'] == 'Berita')
{
$query_art = mysql_query("SELECT * FROM artikel_tbl WHERE type = 'Berita' ORDER BY id") or die(mysql_error());
}
else if ($_POST['type'] == 'Info')
{
$query_art = mysql_query("SELECT * FROM artikel_tbl WHERE type = 'Info' ORDER BY id") or die(mysql_error());
}
else
{
$query_art = mysql_query("SELECT * FROM artikel_tbl ORDER BY id") or die(mysql_error());
}
while($show=mysql_fetch_array($query_art))
{
$no++;
if(($no%2)==0)
$color = '#f2f2f2';
else
$color = '#f9f9f9';
?>
<tr bgcolor="<?php echo $color; ?>" class="rows">
<td class="chk_content"><input type="checkbox" name="checked<?php echo $i; ?>" value="<?php echo $show['id']; ?>"/></td>
<td class="no_content"><?php echo $no; ?></td>
<td class="middle_content"><?php echo $show['judul']; ?></td>
<td class="middle_content"><?php echo $show['penulis']; ?></td>
<td class="middle_content"><?php echo $show['type']; ?></td>
<td class="middle_content"><img src=".././upload/artikel/<?php echo $show['foto']; ?>" width="144" height="88"/></td>
<td class="middle_content"><?php echo $show['tanggal']; ?></td>
<td class="aksi_content"><div id="aksi_table">
<ul>
<li><a href="table_artikel.php?edit=<?php echo $show['id']; ?>"><img src="images/Apps-text-editor-icon.png" width="20" height="20" /></a></li>
<li><a href="table_artikel.php?delete=<?php echo $show['id']; ?>" onclick="return confirm('Hapus artikel?')";><img src="images/Remove-icon.png" width="20" height="20"/></a></li>
</ul>
</div><!-- end of aksi_table --></td>
</tr>
<?php
$i++;
}
?>
<input type="hidden" name="n" value="<?php echo $i; ?>" />
</tbody>
</table>
也許[CodeReview.SE]將是這一個更好的地方。 – Ryan
我建議你閱讀:http://www.brandonsavage.net/how-to-write-a-function-in-php/ – Johan
好的謝謝大家:D – messerchainey