cyberfly 1 Report post Posted March 28, 2008 <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("bowling2") or die(mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php $game[0] = "game1"; $game[1] = "game2"; $game[2] = "game3"; $game[3] = "game4"; $game[4] = "game5"; $game[5] = "game6"; $query="select * from pertandingan where status=1"; $doquery=mysql_query($query) or die(mysql_error()); $array = mysql_fetch_array($doquery); echo $array['idPertandingan']; $limit = $array['bilGame']; for ( $x=0; $x<$limit; $x++ ){ ?> <table width="100%" border="2" cellpadding="2" cellspacing="2" bordercolor="#000000"> <tr> <td></td> <td><form id="form1" name="form1" method="post" action=""> <label> <input type="text" name="$game[$x]" /> </label> </form> </td> </tr> </table><?php } ?> </body> </html>Ni percubaan aku nak buat textfield dlm array.betul ke idea aku tu?nama textfield tu aku buat $game[$x] sbb aku nak masukkan markah dlm table markah.Ni gmbar table pertandingan dlm DB aku..Ni table markah Quote Share this post Link to post Share on other sites
cyberfly 1 Report post Posted March 28, 2008 Aku rasa aku dah jumpa solution.Ni aku pastekan skali untuk rujukan forumers lain <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("bowling2") or die(mysql_error()); ?> <?php if(isset($_POST['submit'])) { $games1 = $_POST['game1']; $games2 = $_POST['game2']; $games3 = $_POST['game3']; $games4 = $_POST['game4']; $games5 = $_POST['game5']; $games6 = $_POST['game6']; $query = "INSERT INTO markah (idPeserta, idPertandingan, game1, game2, game3, game4, game5, game6) VALUES ('14', '2', '$games1', '$games2', '$games3', '$games4', '$games5', '$games6')"; mysql_query($query) or die(mysql_error()); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php $game[0] = "game1"; $game[1] = "game2"; $game[2] = "game3"; $game[3] = "game4"; $game[4] = "game5"; $game[5] = "game6"; $query="select * from pertandingan where status=1"; $doquery=mysql_query($query) or die(mysql_error()); $array = mysql_fetch_array($doquery); echo $array['idPertandingan']; $limit = $array['bilGame']; for ( $x=0; $x<$limit; $x++ ){ ?> <table width="100%" border="2" cellpadding="2" cellspacing="2" bordercolor="#000000"> <form id="form1" name="form1" method="post" action=""> <tr> <td></td> <td> <label> <input type="text" name="<?php echo $game[$x]; ?>" /> </label> </td> </tr> </table><?php } ?> <input type="submit" name="submit" value="Submit" /></form> </body> <label> </label> </body> </html> Quote Share this post Link to post Share on other sites
SHiDi 0 Report post Posted March 28, 2008 Soalan:Kau nak buat banyak column kan? Tapi kena dalam loop kau, ada table? Kalau macam tu bukan ke nanti table yang jadi banyak? Quote Share this post Link to post Share on other sites
cyberfly 1 Report post Posted March 28, 2008 Soalan:Kau nak buat banyak column kan? Tapi kena dalam loop kau, ada table? Kalau macam tu bukan ke nanti table yang jadi banyak?ni experimen je.table tu kan ada satu row je.so loop byk2 pn jadi mcm satu table ada byk row je la kesimpulan,experimen aku berjaya..hehe.. Quote Share this post Link to post Share on other sites