麻辣家族討論版版's Archiver

dragon0kwok 發表於 2012-8-4 23:47

關於form post ID 的問題

<?php
header("Content-Type: text/html; charset=utf-8");
require_once("connMysql.php");

?>

<html>

<head>
<title>Student List</title>
<SCRIPT language=JavaScript>
function reload()
{

for(var i=0; i < document.form1.type.length; i++){
if(document.form1.type[i].checked)
var val=document.form1.type[i].value
}

self.location='list-period-demo.php?type=' + val ;

}
</script>
</head>

<body>
<?


$tp=$_GET['type']; // getting the value from query string
if(strlen($tp) > 1){$query="SELECT name,id FROM student where sex='$tp'";}
else{$query="SELECT name,id FROM student";}
echo $query;
$result = mysql_query ($query);
echo "<form name=form1 method=post action='studentlist.php?id=<?php $nt[id];?>'>
<select name=student value=''>Student Name</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[id]>$nt[name]</option>";
}
echo "</select>";

// radio buttons frm here ///
echo "
<b>Type</b>       
<input type=radio name=type value='male' onclick=\"reload()\";>Male
<input type=radio name=type value='female' onclick=\"reload()\";>Female
<input type=submit value=Submit> </form>";
?>


</body>

</html>

dragon0kwok 發表於 2012-8-4 23:52

補充: 以上是在網路找回來的,不知怎可以POST 的 ID,我想做的是 SUBMIT 之後 POST 個ID指去第二頁,好像 studentlist.php?id=1 之類,希望有人申出援手吧...

gucci 發表於 2012-8-5 00:02

請參考
[url]http://forum.twbts.com/thread-326-1-1.html[/url]

頁: [1]

麻辣家族討論版版為 麻辣學園 網站成員  由 昱得資訊工作室 © Since 1993 所提供