tadapapaya Posted April 11, 2009 Share Posted April 11, 2009 i need help for this... <?php include("validation.php"); ?> <?php $no_staf = $_COOKIE["no_staf"]?> <!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-Script-Type" content="text/javascript"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Permohonan Elaun Perjalanan Kenderaan</title> <link href="innerstyle.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- #apDiv1 { position:absolute; left:542px; top:350px; width:555px; height:31px; z-index:1; } #apDiv2 { position:absolute; left:459px; top:567px; width:529px; height:47px; z-index:2; } .style2 {color: #000000} #apDiv3 { position:absolute; left:40px; top:311px; width:226px; height:201px; z-index:3; } #apDiv4 { position:absolute; left:324px; top:272px; width:77px; height:24px; z-index:4; } #apDiv5 { position:absolute; left:8px; top:272px; width:73px; height:24px; z-index:5; } #apDiv6 { position:absolute; left:93px; top:272px; width:60px; height:24px; z-index:6; } #apDiv7 { position:absolute; left:166px; top:272px; width:149px; height:24px; z-index:7; } #apDiv8 { position:absolute; left:7px; top:273px; width:556px; height:24px; z-index:8; } #apDiv9 { position:absolute; left:298px; top:213px; width:63px; height:23px; z-index:4; } #apDiv10 { position:absolute; left:655px; top:564px; width:188px; height:18px; z-index:4; } .style3 {color: #000000; font-weight: bold; } --> </style> <script type="text/javascript"> function addRowToTable() { var tbl = document.getElementById('kenderaan'); var lastRow = tbl.rows.length; var iteration = lastRow; var row = tbl.insertRow(lastRow); var cellRight1 = row.insertCell(0); var sel = document.createElement('select'); sel.name = 'nama_kelas_perjalanan_kenderaan' + iteration; sel.options[0] = new Option('Sila Pilih', 'Sila Pilih'); sel.options[1] = new Option('500 KM Pertama', '500 KM Pertama'); sel.options[2] = new Option('501 - 1000 KM', '501 - 1000 KM'); sel.options[3] = new Option('1001 - 1700 KM', '1001 - 1700 KM'); sel.options[4] = new Option('1701 KM & Seterusnya', '1701 KM & Seterusnya'); cellRight1.appendChild(sel); var cellRight2 = row.insertCell(1); var el = document.createElement('input'); el.type = 'text'; el.name = 'jarak_perjalanan_kenderaan' + iteration; el.id = 'jarak_perjalanan_kenderaan' + iteration; el.size = 6; cellRight2.appendChild(el); var cellRight3 = row.insertCell(2); var el1 = document.createElement('input'); el1.type = 'text'; el1.name = 'kadar_cas_perjalanan_kenderaan' + iteration; el1.id = 'kadar_cas_perjalanan_kenderaan' + iteration; el1.size = 6; cellRight3.appendChild(el1); var cellRight4 = row.insertCell(3); var el2 = document.createElement('input'); el2.type = 'text'; el2.name = 'jumlah_perjalanan_kenderaan' + iteration; el2.id = 'jumlah_perjalanan_kenderaan' + iteration; el2.size = 10; cellRight4.appendChild(el2); } function removeRowFromTable() { var tbl = document.getElementById('kenderaan'); var lastRow = tbl.rows.length; if (lastRow > 2) tbl.deleteRow(lastRow - 1); } </script> <script type="text/javascript"> <!-- function myPopup2() { window.open( "kadar_perjalanan_kenderaan.php", "myWindow", "status = 1, height = 350, width = 550, resizable = 0" ) } //--> </script> <script type='text/javascript'> function formValidator(){ var nama_kelas_perjalanan_kenderaan = document.getElementById('nama_kelas_perjalanan_kenderaan'); var jarak_perjalanan_kenderaan = document.getElementById('jarak_perjalanan_kenderaan'); var kadar_cas_perjalanan_kenderaan = document.getElementById('kadar_cas_perjalanan_kenderaan'); var jumlah_perjalanan_kenderaan = document.getElementById('jumlah_perjalanan_kenderaan'); var jumlah_kesemua_perjalanan_kenderaan = document.getElementById('jumlah_kesemua_perjalanan_kenderaan'); if(madeSelection(nama_kelas_perjalanan_kenderaan, "Sila Pilih Jarak Perjalanan")){ if(isNumeric(jarak_perjalanan_kenderaan, "Sila Masukkan Jarak Perjalanan")){ if(isFloat(kadar_cas_perjalanan_kenderaan, "Sila Masukkan Kadar Cas")){ if(isFloat(jumlah_perjalanan_kenderaan, "Sila Masukkan Jumlah")){ if(isFloat(jumlah_kesemua_perjalanan_kenderaan, "Sila Masukkan Jumlah Keseluruhan")){ return true; } } } } } return false; } function madeSelection(elem, helperMsg){ if(elem.value == "Sila Pilih"){ alert(helperMsg); elem.focus(); return false; }else{ return true; } } function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isFloat(elem, helperMsg){ var float = /^[0-9]+\.[0-9]+$/; if(elem.value.match(float)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } </script> <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script> </head> <body> <div id="apDiv1"> <?php mysql_connect("localhost"); mysql_select_db (tuntutan); $sambung=mysql_connect("localhost"); if(!$sambung) die("gagal disambungkan".mysql_error()); $db="tuntutan"; mysql_select_db($db) or die("Gagal sambung ke dbase: $db".mysql_error()); $query="SELECT * from tuntutan WHERE no_staf='$no_staf'"; $result=mysql_query($query); if($myrow=mysql_fetch_array($result)){ $no_tuntutan =$myrow["no_tuntutan"]; } ?> <form id="mohon_kenderaan" name="kenderaan" method="post" action="perjalanan_kenderaan_proses.php"> <input type="hidden" name="no_staf" value="<?echo $_COOKIE['no_staf']?>"> <input type="hidden" name="no_tuntutan" value="<?echo $no_tuntutan?>"> <table border="1" id="kenderaan"> <tr> <td><div align="center"><strong><span class="style2">Pilihan Jarak</span></strong></div></td> <td><div align="center"><strong><span class="style2">Jarak</span></strong></div></td> <td><div align="center"><strong><span class="style2">Kadar</span></strong></div></td> <td><div align="center"><strong><span class="style2">Jumlah</span></strong></div></td> </tr> <tr> <td><select name="nama_kelas_perjalanan_kenderaan" id="nama_kelas_perjalanan_kenderaan"> <option>Sila Pilih</option> <option>500 KM Pertama</option> <option>501 - 1000 KM</option> <option>1001 - 1700 KM</option> <option>1701 KM & Seterusnya</option> </select></td> <td><input name="jarak_perjalanan_kenderaan" type="text" id="jarak_perjalanan_kenderaan" size="6" maxlength="5"/></td> <td><input name="kadar_cas_perjalanan_kenderaan" type="text" id="kadar_cas_perjalanan_kenderaan" size="6" maxlength="5"/></td> <td><input name="jumlah_perjalanan_kenderaan" type="text" id="jumlah_perjalanan_kenderaan" size="10" maxlength="6"/></td> </tr> </table> <div id="apDiv8"> <input type="submit" name="butang" id="butang" value="Simpan" onclick='return formValidator()' /> <input type="submit" name="butang" id="butang" value="Simpan & Seterusnya" onclick='return formValidator()' /> <input type="reset" name="butang" id="butang" value="Kosongkan" /> <input type="button" name="butang" id="butang" value="Tambah" onclick='addRowToTable();' /> <input type="button" value="Buang" onclick="removeRowFromTable();" /> <input type="button" name="butang" id="butang" value="Kadar" onClick="myPopup2()" /> </div> <div id="apDiv9"> <label> <input type="text" name="jumlah_kesemua_perjalanan_kenderaan" id="jumlah_kesemua_perjalanan_kenderaan" size="10" maxlength="8"/> </label> </div> </form> </div> <div id="apDiv3"> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button1','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button1' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button1.swf" /> <param name="quality" value="high" /> <embed src="button1.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button2' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button2.swf" /> <param name="quality" value="high" /> <embed src="button2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button14','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button14' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button14.swf" /> <param name="quality" value="high" /> <embed src="button14.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button3','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button3' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button3.swf" /> <param name="quality" value="high" /> <embed src="button3.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button12','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','button12' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="movie" value="button12.swf" /> <param name="quality" value="high" /> <embed src="button12.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button4','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button4' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button4.swf" /> <param name="quality" value="high" /> <embed src="button4.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button5','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button5' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button5.swf" /> <param name="quality" value="high" /> <embed src="button5.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button6','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button6' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button6.swf" /> <param name="quality" value="high" /> <embed src="button6.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button7','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button7' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button7.swf" /> <param name="quality" value="high" /> <embed src="button7.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button8','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button8' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button8.swf" /> <param name="quality" value="high" /> <embed src="button8.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button9','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button9' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button9.swf" /> <param name="quality" value="high" /> <embed src="button9.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button13','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','button13' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="movie" value="button13.swf" /> <param name="quality" value="high" /> <embed src="button13.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button11','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button11' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button11.swf" /> <param name="quality" value="high" /> <embed src="button11.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> <p> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0','width','265','height','45','src','button10','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','bgcolor','','movie','button10' ); //end AC code </script> <noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="265" height="45"> <param name="BGCOLOR" value="" /> <param name="movie" value="button10.swf" /> <param name="quality" value="high" /> <embed src="button10.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="265" height="45" ></embed> </object> </noscript> </p> </div> <div class="style3" id="apDiv10">JUMLAH KESEMUA RM</div> <div id="header"> <ul class="nav"> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> <a href="halaman_utama.html"><img src="images/logo.gif" alt="efficient" width="390" height="102" border="0" class="logo" /></a> <ul class="sub"> <li></li> <li></li> <li></li> </ul> </div> <!--header end --> <!--body start --> <div id="body"> <!--left start --> <!--left end --> <!--mid start --> <!--mid end --> <!--tight start --> <div id="right"> <p><br class="spacer" /> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p><br class="spacer" /> </p> </div> <div id="left"> <!--event start --> <div id=""> <p align="center"><br /> <span class="body1text style2">PERMOHONAN ELAUN PERJALANAN KENDERAAN</span></p> <p> </p> <p><br class="spacer" /> </p> </div> </div> <!--tight end --> <br class="spacer" /> </div> <!--body end --> <!--footer start --> <div id="footerMain"> <div id="footer"> <p class="copyright">Copyright © Sistem Tuntutan 2009</p> <p class="design"> </p> </div> </div> <!--footer end --> </body> </html> <?php include("validation.php"); ?> <?php $no_staf = $_COOKIE["no_staf"]?> <html> <head> <title>Perjalanan Kenderaan</title> </head> <body> <script language= "PHP"> if(isset($butang)) { if($butang=="Simpan") { simpandata($no_tuntutan,$no_staf,$nama_kelas_perjalanan_kenderaan,$jarak_perjalanan_kenderaan,$kadar_cas_perjalanan_kenderaan,$jumlah_perjalanan_kenderaan,$jumlah_kesemua_perjalanan_kenderaan); } else if($butang=="Simpan & Seterusnya") { simpandata2($no_tuntutan,$no_staf,$nama_kelas_perjalanan_kenderaan,$jarak_perjalanan_kenderaan,$kadar_cas_perjalanan_kenderaan,$jumlah_perjalanan_kenderaan,$jumlah_kesemua_perjalanan_kenderaan); } } function simpandata2($no_tuntutan,$no_staf,$nama_kelas_perjalanan_kenderaan,$jarak_perjalanan_kenderaan,$kadar_cas_perjalanan_kenderaan,$jumlah_perjalanan_kenderaan,$jumlah_kesemua_perjalanan_kenderaan) { $db="tuntutan"; $link=mysql_pconnect("localhost"); if(!$link) { $dberror="Couldn't connect to mysql"; } if(!mysql_select_db($db,$link)) { $dberror=mysql_error(); } $query="INSERT INTO perjalanan_kenderaan (no_tuntutan,no_staf,nama_kelas_perjalanan_kenderaan,jarak_perjalanan_kenderaan,kadar_cas_perjalanan_kenderaan,jumlah_perjalanan_kenderaan,jumlah_kesemua_perjalanan_kenderaan) VALUES ('$no_tuntutan','$no_staf','$nama_kelas_perjalanan_kenderaan','$jarak_perjalanan_kenderaan','$kadar_cas_perjalanan_kenderaan','$jumlah_perjalanan_kenderaan','$jumlah_kesemua_perjalanan_kenderaan')"; if (!mysql_query($query,$link)) { $dberror=mysql_error(); echo "error".$dberror; } echo "<script>" ."alert('Tahniah! Data Anda Telah Berjaya Disimpan!');" ."</script>"; echo"<script>"; echo "location.href='pengangkutan_awam.php'"; echo "</script>"; mysql_close($link); } echo "<script>" ."alert('Harap Maaf! Data Anda Tidak Berjaya Disimpan!');" ."</script>"; echo"<script>"; echo "location.href='lepas_login.php'"; function simpandata($no_tuntutan,$no_staf,$nama_kelas_perjalanan_kenderaan,$jarak_perjalanan_kenderaan,$kadar_cas_perjalanan_kenderaan,$jumlah_perjalanan_kenderaan,$jumlah_kesemua_perjalanan_kenderaan) { $db="tuntutan"; $link=mysql_pconnect("localhost"); if(!$link) { $dberror="Couldn't connect to mysql"; } if(!mysql_select_db($db,$link)) { $dberror=mysql_error(); } for($i=0; $i<count($_POST['jarak_perjalanan_kenderaan']); $i++ ){ $query="INSERT INTO perjalanan_kenderaan (no_tuntutan,no_staf,nama_kelas_perjalanan_kenderaan,jarak_perjalanan_kenderaan,kadar_cas_perjalanan_kenderaan,jumlah_perjalanan_kenderaan,jumlah_kesemua_perjalanan_kenderaan) VALUES ('$no_tuntutan','$no_staf','$nama_kelas_perjalanan_kenderaan','$jarak_perjalanan_kenderaan','$kadar_cas_perjalanan_kenderaan','$jumlah_perjalanan_kenderaan','$jumlah_kesemua_perjalanan_kenderaan')"; if (!mysql_query($query,$link)) { $dberror=mysql_error(); echo "error".$dberror; } echo "<script>" ."alert('Tahniah! Data Anda Telah Berjaya Disimpan!');" ."</script>"; echo"<script>"; echo "location.href='lepas_login.php'"; echo "</script>"; mysql_close($link); } echo "<script>" ."alert('Harap Maaf! Data Anda Tidak Berjaya Disimpan!');" ."</script>"; echo"<script>"; echo "location.href='lepas_login.php'"; } </script> </body> </html> when user click "Tambah", a new row will appear..but,when clicked "Simpan" & "Simpan & Seterusnya", only the first row inserted into database... Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/ Share on other sites More sharing options...
Mchl Posted April 11, 2009 Share Posted April 11, 2009 http://www.phpfreaks.com/page/forum-rules Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807520 Share on other sites More sharing options...
jackpf Posted April 11, 2009 Share Posted April 11, 2009 Yeah...that's not really a specific question. Plus, I don't think anyone's actually going to read that code. Be more concise. Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807524 Share on other sites More sharing options...
tadapapaya Posted April 11, 2009 Author Share Posted April 11, 2009 what should i do? Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807565 Share on other sites More sharing options...
jackpf Posted April 11, 2009 Share Posted April 11, 2009 Uhh...you could try posting an actual question, and displaying the relevant code for that question. Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807571 Share on other sites More sharing options...
redarrow Posted April 11, 2009 Share Posted April 11, 2009 WTF. Not got 10 years, what the problem please. Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807573 Share on other sites More sharing options...
jackpf Posted April 11, 2009 Share Posted April 11, 2009 Lol, see what I mean. Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807579 Share on other sites More sharing options...
tadapapaya Posted April 11, 2009 Author Share Posted April 11, 2009 okey....this the form,php.... <script type="text/javascript"> function addRowToTable() { var tbl = document.getElementById('kenderaan'); var lastRow = tbl.rows.length; var iteration = lastRow; var row = tbl.insertRow(lastRow); var cellRight1 = row.insertCell(0); var sel = document.createElement('select'); sel.name = 'nama_kelas_perjalanan_kenderaan' + iteration; sel.options[0] = new Option('Sila Pilih', 'Sila Pilih'); sel.options[1] = new Option('500 KM Pertama', '500 KM Pertama'); sel.options[2] = new Option('501 - 1000 KM', '501 - 1000 KM'); sel.options[3] = new Option('1001 - 1700 KM', '1001 - 1700 KM'); sel.options[4] = new Option('1701 KM & Seterusnya', '1701 KM & Seterusnya'); cellRight1.appendChild(sel); var cellRight2 = row.insertCell(1); var el = document.createElement('input'); el.type = 'text'; el.name = 'jarak_perjalanan_kenderaan' + iteration; el.id = 'jarak_perjalanan_kenderaan' + iteration; el.size = 6; cellRight2.appendChild(el); var cellRight3 = row.insertCell(2); var el1 = document.createElement('input'); el1.type = 'text'; el1.name = 'kadar_cas_perjalanan_kenderaan' + iteration; el1.id = 'kadar_cas_perjalanan_kenderaan' + iteration; el1.size = 6; cellRight3.appendChild(el1); var cellRight4 = row.insertCell(3); var el2 = document.createElement('input'); el2.type = 'text'; el2.name = 'jumlah_perjalanan_kenderaan' + iteration; el2.id = 'jumlah_perjalanan_kenderaan' + iteration; el2.size = 10; cellRight4.appendChild(el2); } function removeRowFromTable() { var tbl = document.getElementById('kenderaan'); var lastRow = tbl.rows.length; if (lastRow > 2) tbl.deleteRow(lastRow - 1); } </script> <table border="1" id="kenderaan"> <tr> <td><div align="center"><strong><span class="style2">Pilihan Jarak</span></strong></div></td> <td><div align="center"><strong><span class="style2">Jarak</span></strong></div></td> <td><div align="center"><strong><span class="style2">Kadar</span></strong></div></td> <td><div align="center"><strong><span class="style2">Jumlah</span></strong></div></td> </tr> <tr> <td><select name="nama_kelas_perjalanan_kenderaan" id="nama_kelas_perjalanan_kenderaan"> <option>Sila Pilih</option> <option>500 KM Pertama</option> <option>501 - 1000 KM</option> <option>1001 - 1700 KM</option> <option>1701 KM & Seterusnya</option> </select></td> <td><input name="jarak_perjalanan_kenderaan" type="text" id="jarak_perjalanan_kenderaan" size="6" maxlength="5"/></td> <td><input name="kadar_cas_perjalanan_kenderaan" type="text" id="kadar_cas_perjalanan_kenderaan" size="6" maxlength="5"/></td> <td><input name="jumlah_perjalanan_kenderaan" type="text" id="jumlah_perjalanan_kenderaan" size="10" maxlength="6"/></td> </tr> </table> <input type="button" name="butang" id="butang" value="Tambah" onclick='addRowToTable();' /> <input type="button" value="Buang" onclick="removeRowFromTable();" /> <input type="submit" name="butang" id="butang" value="Simpan" /> this is the mysql... if(isset($butang)) { if($butang=="Simpan") { simpandata($no_tuntutan,$no_staf,$nama_kelas_perjalanan_kenderaan,$jarak_perjalanan_kenderaan,$kadar_cas_perjalanan_kenderaan,$jumlah_perjalanan_kenderaan,$jumlah_kesemua_perjalanan_kenderaan); } } function simpandata($no_tuntutan,$no_staf,$nama_kelas_perjalanan_kenderaan,$jarak_perjalanan_kenderaan,$kadar_cas_perjalanan_kenderaan,$jumlah_perjalanan_kenderaan,$jumlah_kesemua_perjalanan_kenderaan) { $db="tuntutan"; $link=mysql_pconnect("localhost"); if(!$link) { $dberror="Couldn't connect to mysql"; } if(!mysql_select_db($db,$link)) { $dberror=mysql_error(); } for($i=0; $i<count($_POST['jarak_perjalanan_kenderaan']); $i++ ){ $query="INSERT INTO perjalanan_kenderaan (no_tuntutan,no_staf,nama_kelas_perjalanan_kenderaan,jarak_perjalanan_kenderaan,kadar_cas_perjalanan_kenderaan,jumlah_perjalanan_kenderaan,jumlah_kesemua_perjalanan_kenderaan) VALUES ('$no_tuntutan','$no_staf','$nama_kelas_perjalanan_kenderaan','$jarak_perjalanan_kenderaan','$kadar_cas_perjalanan_kenderaan','$jumlah_perjalanan_kenderaan','$jumlah_kesemua_perjalanan_kenderaan')"; if (!mysql_query($query,$link)) { $dberror=mysql_error(); echo "error".$dberror; } echo "<script>" ."alert('Tahniah! Data Anda Telah Berjaya Disimpan!');" ."</script>"; echo"<script>"; echo "location.href='lepas_login.php'"; echo "</script>"; mysql_close($link); } echo "<script>" ."alert('Harap Maaf! Data Anda Tidak Berjaya Disimpan!');" ."</script>"; echo"<script>"; echo "location.href='lepas_login.php'"; } when user click "Tambah" it add a new row.. user enter all the value... when user click "Simpan", in database,it only save the first row of data... and what i need is, if the user have 3 rows of data, it all will inserted into database.. not only the first row... sorry for my broken english.. Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807590 Share on other sites More sharing options...
jackpf Posted April 11, 2009 Share Posted April 11, 2009 You could try putting [] on the end of the input name. That way PHP puts it into an array when posting it. Eg <?php //form echo '<input type="text" name="name[]" />'; //PHP processing $post = $_POST['name']; foreach($post as $key => $value) { mysql_query(...put your query here } ?> Hope that works. Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807600 Share on other sites More sharing options...
tadapapaya Posted April 11, 2009 Author Share Posted April 11, 2009 it does not work... this is the result... Array ( [no_staf] => udm/01/001 [no_tuntutan] => 4 [nama_kelas_perjalanan_kenderaan] => Array ( [0] => 500 KM Pertama ) [jarak_perjalanan_kenderaan] => Array ( [0] => 121 ) [kadar_cas_perjalanan_kenderaan] => Array ( [0] => 12.00 ) [jumlah_perjalanan_kenderaan] => Array ( [0] => 12.00 ) [nama_kelas_perjalanan_kenderaan2] => 501 - 1000 KM [jarak_perjalanan_kenderaan2] => 121 [kadar_cas_perjalanan_kenderaan2] => 12.00 [jumlah_perjalanan_kenderaan2] => 12.00 [nama_kelas_perjalanan_kenderaan3] => 1001 - 1700 KM [jarak_perjalanan_kenderaan3] => 12 [kadar_cas_perjalanan_kenderaan3] => 12.00 [jumlah_perjalanan_kenderaan3] => 12.00 [butang] => Simpan [jumlah_kesemua_perjalanan_kenderaan] => 12.00 ) 1 Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807613 Share on other sites More sharing options...
tadapapaya Posted April 12, 2009 Author Share Posted April 12, 2009 someone please help me..... Quote Link to comment https://forums.phpfreaks.com/topic/153670-help-meurgent/#findComment-807708 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.