ใช้ form รับข้อมูลมาเป็นค่า id กับ class แล้วจะใช้เป็นตัวแปรเพื่อเปรียบเทียบดึงข้อมูลจากตารางแต่ละตารางอย่างไร
แบบว่า ถ้า class=1/1 ให้ไปดึงค่าจากตาราง m1 มาแสดง class=2/1 ดึงค่าจากตาราง m2 มาแสดง เป็นต้น
ผมเขียนลักษระนี้ แต่ยังไม่ได้
$id = $_POST["id"];
$class = $_POST["class"];
$class1=substr($class,0,1);
$class2=substr($class,1,1);
$class3="/";
$classc=$class1.$class3.$class2;
if ($id=="" || $class=="")
{
print "<font size=+2>คุณกรอกข้อมูลไม่ครบ</font>";
exit();
}
$link = mysql_connect( "localhost" , "root" , "123456" );
if (!$link)
{
print "Error connecting";
exit();
}
mysql_select_db( "score50", $link );
switch ($classc) {
case "1";
$sql="select * from m1y2550 where id='$id' and class='$class'"; break;
case "2";
$sql="select * from m2y2550 where id='$id' and class='$class'"; break;
case "3";
$sql="select * from m3y2550 where id='$id' and class='$class'"; break;
default;
$sql="select * from m4y2550 where id='$id' and class='$class'"; }