|
Originally posted by pzan213 at 8-2-2009 05:47 PM
hmm..kalo nak buat pakai ape yee?
http://g.imagehost.org/0053/untitled.jpg
yg ni aku amik cth dr blogspot..
so nanti bile kite add another tu dier akan kuar textfield..ikut brape byk yg ...
guna javascript
- <script language="javascript">
- function addRow(objInput){
- if(!objInput){objInput=0;}
- var nextId=objInput+1;
- var objOutput="<div><input type="text" name="filename[]">";
- objOutput+="<span id="item_"+nextId+""><span></div>";
- document.getElementById("item_"+objInput).innerHTML=objOutput;
- var button="<input type="button" value="Add New Field" onclick="addRow("+nextId+")" />";
- document.getElementById("add").innerHTML=button;}
- </script>
Copy the Code
n ko letak kat form
- <input type="text" name="filename[]" />
- <span id="item_0"></span><br />
- <span id="add"><input type="button" value="Add New Field" onclick="addRow(1)" />
Copy the Code |
|
|
|
|
|
|
|
dah try..tp klik button add..dier xkuar pun next texfield..??
[quote]
<script language="javascript">
function addRow(objInput){
if(!objInput){objInput=0;}
var nextId=objInput+1;
var objOutput="<div><input type=\"text\" name=\"filename[]\">";
objOutput+="<span id=\"item_"+nextId+"\"><span></div>";
document.getElementById("item_"+objInput).innerHTML=objOutput;
var button="<input type=\"button\" value=\"Add New Field\" onclick=\"addRow("+nextId+")\" />";
document.getElementById("add").innerHTML=button;}
</script>
<body>
<form action="test2.php" method="post">
<input type="text" name="filename[]" />
<span id="item_0"> </span><br />
<span id="add"><input type="button" value="Add New Field" onclick="addRow(1)" /></span>
</form>
</body>
[quote] |
|
|
|
|
|
|
|
ko tukar onclick="addRow(1)" ke onclick="addRow(0)" |
|
|
|
|
|
|
|
thanks..dah boleh.. |
|
|
|
|
|
|
|
board....daripada yg textfield yg leh tmbh2 tu..cane nak post dier n nak simpan dlm db...
$nokp=$_POST['filename[]'];
camtu ke? |
|
|
|
|
|
|
|
for($i=0; $i<count($_POST['filename']); $i++)
{
mysql_query("INSERT INTO table (filename) VALUES ('". $_POST['filename'][$i] ."')");
} |
|
|
|
|
|
|
|
boardmanager...nak selit celah mane ek..dah puas aku selit..xmenjadi gak...
kat coding ni yg filename tu aku dah tukar kpd nokp..aku gune add textfield tu utk isi nokp.
for($i=0; $i<count($_POST['nokp']); $i++)
{
  mysql_query("INSERT INTO table (nokp) VALUES ('". $_POST['nokp'][$i] ."')");
}
$nama=$_POST['nama'];
$catatan=$_POST['catatan'];
$tindakan=$_POST['tindakan'];
$tarikh=$_POST['tarikh'];
No KP : cane nak papar no kp yg kite post kat sini?
tarikh : <input name="tarikh" type="text" id="tarikh" value=<? echo date('j-F-Y'); ?> readonly>
Catatan:<textarea name="catatan" cols="63" rows="5" id="catatan" readonly><? echo"$catatan"; ?></textarea>
Tindakan: <textarea name="tindakan" cols="63" rows="5" id="tindakan" readonly><? echo"$tindakan"; ?></textarea>
<?php
if (isset($_REQUEST['Submit'])) {
$sql = "INSERT INTO rekodkelompok (nokp,nokp2,tarikh,catatan,tindakan) values('".mysql_real_escape_string(stripslashes($_REQUEST['nokp']))."','$nokp2','".mysql_real_escape_string(stripslashes($_REQUEST['tarikh']))."' ,'".mysql_real_escape_string(stripslashes($_REQUEST['catatan']))."' ,'".mysql_real_escape_string(stripslashes($_REQUEST['tindakan']))."' )";
if($result = mysql_query($sql ,$db)) {
echo ""; ?>
  <script language=javascript>
  window.alert ("Mesej Telah Dihantar");
  </script> <?
} else {
echo "ERROR: ".mysql_error();
}
} else {}
?> |
|
|
|
|
|
|
|
ok..ni full script..ader 2 page..
rekodkelompok.php
<?
session_start();
if(!session_is_registered(nokp2)){
header("location:loginkaunselor.php");
}
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="1234"; // Mysql password
$db_name="nurani"; // Database name
$tbl_name="rekodindividu"; // Table name
$db = mysql_connect($host, $username, $password);
if (!$db)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db($db_name,$db);
$sql = "SELECT * FROM kaunselor WHERE nokp2 = '". $_SESSION['nokp2'] ."'"; 
$result = mysql_query($sql) or die("SQL select statement failed");
while ($row = mysql_fetch_array($result)) {
  $nama=$row["nama"];
  $email=$row["email"];
  $nokp2=$row["nokp2"];
   
  }
 $row = mysql_fetch_assoc($result);
 
//mysql_close($con);  
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" c>
<link rel="stylesheet" type="text/css" href="style2.css" />
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<script language="javascript">
function addRow(objInput){
if(!objInput){objInput=0;}
var nextId=objInput+1;
var objOutput="<div><input type=\"text\" name=\"filename[]\">";
objOutput+="<span id=\"item_"+nextId+"\"><span></div>";
document.getElementById("item_"+objInput).innerHTML=objOutput;
var button=" <input type=\"button\" value=\"Tambah\" onclick=\"addRow("+nextId+")\" />";
document.getElementById("add").innerHTML=button;}
</script>
</head>
<body>
<div id="Layer1" style="position:absolute; left:120px; top:42px; width:925px; height:620px; z-index:1; background-color: #F6E8A5; layer-background-color: #F6E8A5; border: 1px none #000000;"> 
  <br><div align="center"><hr width="910"></div>
  <div align="center"> </div>
  <p><br>
  <br>
  </p>
  <p> </p>
  <p> </p>
  <div id="Layer4" style="position:absolute; left:299px; top:73px; width:603px; height:211px; z-index:4"> 
  <form action="rekodkelompok2.php" method="post">
   
  <div align="center"></div>
  <table width="97%" border="1" align="center">
  <tr>
  <td bgcolor="#FFFFFF"><p align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Rekod 
  Kaunseling Kelompok </strong></font><br>
  <br>
  <strong><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">No KP</font></strong><br>
  <input type="text" name="filename[]" /><br>
  <span id="item_0"> </span>
  <span id="add"> 
  <input name="button" type="button" value="Tambah No KP" />
  </span></p> <br>
  <strong><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Tarikh :</font></strong>
  <input name="tarikh" type="text" id="tarikh" value=<? echo date('j-F-Y'); ?> readonly>
  <br><br>
  <font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"> <strong>Catatan 
  Pertemuan :</strong><br>
   
  <textarea name="catatan" cols="63" rows="5" id="catatan"></textarea>
  <br>
  <br>
  <strong>Tindakan :</strong><br>
   
  <textarea name="tindakan" cols="63" rows="5" id="tindakan"></textarea>
  </font><br>
  <br>
  <p> </p></td>
  </tr>
  </table>
  <br/>
  <input type="submit" name="Submit" value="Hantar">
   
</form>
<br/>  
<div align="center"> </div>
  </div>
  <p> </p>
  <p> </p>
  <div id="Layer5" style="position:absolute; left:27px; top:177px; width:237px; height:149px; z-index:5"> 
  <table width="100%" border="1">
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#005381"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Status 
  online Kaunselor</strong></font></div></td>
  </tr>
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Kaunselor 
  1</strong></font></div></td>
  </tr>
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"><a href="ymsgr:sendIM?pzan213&m=YOUR+MESSAGE"><img border="0" src="http://opi.yahoo.com/online?u=pzan213&m=g&t=2"/></a></div></td>
  </tr>
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Kaunselor 
  2</strong></font></div></td>
  </tr>
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"><a href="ymsgr:sendIM?pzan213&m=YOUR+MESSAGE"><img border="0" src="http://opi.yahoo.com/online?u=pzan213&m=g&t=2"/></a></div></td>
  </tr>
  </table>
  </div>
  <p> </p>
  <p> </p>
  <div id="Layer5" style="position:absolute; left:300px; top:40px; width:587px; height:30px; z-index:5"> 
  <table width="101%" border="1">
  <tr> 
  <td bgcolor="#005381"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Rekod 
  Maklumat Kaunseling Individu</strong></font></div></td>
  </tr>
  </table>
  </div>
  <p> </p>
  <br><br><br><br><br><br><br><br><br><br><div align="center"><hr width="910"></div>
</div>
<div id="Layer2" style="position:absolute; left:118px; top:11px; width:928px; height:25px; z-index:2"> 
  <table width="100%" border="1" align="center">
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#005381"><div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong> 
  <marquee>
  <font color="#FFFFFF">Selamat Datang <?php echo"$nama"; ?> </font> 
  </marquee>
  </strong></font></div></td>
  </tr>
  </table>
</div>
<div id="Layer3" style="position:absolute; left:120px; top:665px; width:927px; height:10px; z-index:3"> 
  <table width="100%" border="1" align="center">
  <tr> 
  <td bgcolor="#005381"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>© 
  2009 P_zaN v Mat_PiH @ UPSI</strong></font></div></td>
  </tr>
  </table>
</div>
<div id="Layer5" style="position:absolute; left:147px; top:84px; width:234px; height:75px; z-index:5"> 
  <table width="101%" border="1">
  <tr> 
  <td width="18%" bordercolor="#FFFFCC" bgcolor="#005381"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Rekod Kaunseling</strong></font></div></td>
  </tr>
  <tr> 
  <td width="18%" bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"> 
  <div id="menu"> 
  <dt ><a href="rekodindividu.php" target="mainFrame"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Rekod Individu</font></a></dt>
  </div>
  </div></td>
  </tr>
  <tr> 
  <td width="18%" bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"> 
  <div id="menu"> 
  <dt ><a href="rekodkelompok.php" target="mainFrame"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Rekod Kelompok</font></a></dt>
  </div>
  </div></td>
  </tr>
 <tr> 
  <td width="18%" bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"> 
  <div id="menu"> 
  <dt ><a href="laporan.php" target="mainFrame"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Laporan</font></a></dt>
  </div>
  </div></td>
  </tr>
  </table>
</div>
<div id="Layer6" style="position:absolute; left:146px; top:396px; width:247px; height:30px; z-index:6">
 
</div>
</body>
</html>
rekodkelompok2.php
<?
session_start();
if(!session_is_registered(nokp2)){
header("location:loginkaunselor.php");
}
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="1234"; // Mysql password
$db_name="nurani"; // Database name
$tbl_name="rekodindividu"; // Table name
$db = mysql_connect($host, $username, $password);
if (!$db)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db($db_name,$db);
$sql = "SELECT * FROM kaunselor WHERE nokp2 = '". $_SESSION['nokp2'] ."'"; 
$result = mysql_query($sql) or die("SQL select statement failed");
while ($row = mysql_fetch_array($result)) {
  $nama=$row["nama"];
  $email=$row["email"];
  $nokp2=$row["nokp2"];
   
  }
 $row = mysql_fetch_assoc($result);
 
//mysql_close($con);  
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" c>
<link rel="stylesheet" type="text/css" href="style2.css" />
<script language="javascript">
function addRow(objInput){
if(!objInput){objInput=0;}
var nextId=objInput+1;
var objOutput="<div><input type=\"text\" name=\"nokp[]\">";
objOutput+="<span id=\"item_"+nextId+"\"><span></div>";
document.getElementById("item_"+objInput).innerHTML=objOutput;
var button=" <input type=\"button\" value=\"Tambah\" onclick=\"addRow("+nextId+")\" />";
document.getElementById("add").innerHTML=button;}
</script>
</head>
<body>
<? 
$nama=$_POST['nama'];
$catatan=$_POST['catatan'];
$tindakan=$_POST['tindakan'];
$tarikh=$_POST['tarikh'];
$nokp =$_POST['filename'][$i];
?>
<div id="Layer1" style="position:absolute; left:120px; top:42px; width:925px; height:620px; z-index:1; background-color: #F6E8A5; layer-background-color: #F6E8A5; border: 1px none #000000;"> 
  <br><div align="center"><hr width="910"></div>
  <div align="center"> </div>
  <p><br>
  <br>
  </p>
  <p> </p>
  <p> </p>
  <div id="Layer4" style="position:absolute; left:301px; top:71px; width:603px; height:211px; z-index:4"> 
  <form action="rekodkelompok2.php" method="post">
   
  <div align="center"></div>
  <table width="97%" border="1" align="center">
  <tr>
  <td bgcolor="#FFFFFF"><p align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Rekod 
  Kaunseling Kelompok </strong></font><br>
  <br></p>
  <strong><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">No KP</font></strong><br>
  <br><? echo"$nokp"; ?>
  <strong><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Tarikh :</font></strong>
  <input name="tarikh" type="text" id="tarikh" value=<? echo date('j-F-Y'); ?> readonly>
  <br><br>
  <font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"> <strong>Catatan 
  Pertemuan :</strong><br>
   
  <textarea name="catatan" cols="63" rows="5" id="catatan" readonly><? echo"$catatan"; ?></textarea>
  <br>
  <br>
  <strong>Tindakan :</strong><br>
   
  <textarea name="tindakan" cols="63" rows="5" id="tindakan" readonly><? echo"$tindakan"; ?></textarea>
  </font><br>
  <br>
  <p> </p></td>
  </tr>
  </table>
  <br/>
   
 <table align=center border="1" width="97%" bgcolor="#FFFFFF">
 <tr>
  </tr>
</table>
</form>
<?php
if (isset($_REQUEST['Submit'])) {
$sql = "INSERT INTO rekodkelompok (nokp,nokp2,tarikh,catatan,tindakan) values ('".mysql_real_escape_string(stripslashes($_POST['filename'][$i]))."','$nokp2','".mysql_real_escape_string(stripslashes($_REQUEST['tarikh']))."' ,'".mysql_real_escape_string(stripslashes($_REQUEST['catatan']))."' ,'".mysql_real_escape_string(stripslashes($_REQUEST['tindakan']))."' )";
if($result = mysql_query($sql ,$db)) {
echo ""; ?>
  <script language=javascript>
  window.alert ("Mesej Telah Dihantar");
  </script> <?
} else {
echo "ERROR: ".mysql_error();
}
} else {}
?>
  </div>
  <p> </p>
  <p> </p>
  <div id="Layer5" style="position:absolute; left:27px; top:177px; width:237px; height:149px; z-index:5"> 
  <table width="100%" border="1">
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#005381"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Status 
  online Kaunselor</strong></font></div></td>
  </tr>
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Kaunselor 
  1</strong></font></div></td>
  </tr>
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"><a href="ymsgr:sendIM?pzan213&m=YOUR+MESSAGE"><img border="0" src="http://opi.yahoo.com/online?u=pzan213&m=g&t=2"/></a></div></td>
  </tr>
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Kaunselor 
  2</strong></font></div></td>
  </tr>
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"><a href="ymsgr:sendIM?pzan213&m=YOUR+MESSAGE"><img border="0" src="http://opi.yahoo.com/online?u=pzan213&m=g&t=2"/></a></div></td>
  </tr>
  </table>
  </div>
  <p> </p>
  <p> </p>
  <div id="Layer5" style="position:absolute; left:300px; top:40px; width:587px; height:30px; z-index:5"> 
  <table width="101%" border="1">
  <tr> 
  <td bgcolor="#005381"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Rekod 
  Maklumat Kaunseling Individu</strong></font></div></td>
  </tr>
  </table>
  </div>
  <p> </p>
  <br><br><br><br><br><br><br><br><br><div align="center"><hr width="910"></div>
</div>
<div id="Layer2" style="position:absolute; left:118px; top:11px; width:928px; height:25px; z-index:2"> 
  <table width="100%" border="1" align="center">
  <tr> 
  <td bordercolor="#FFFFCC" bgcolor="#005381"><div align="center"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong> 
  <marquee>
  <font color="#FFFFFF">Selamat Datang <?php echo"$nama"; ?> </font> 
  </marquee>
  </strong></font></div></td>
  </tr>
  </table>
</div>
<div id="Layer3" style="position:absolute; left:120px; top:665px; width:927px; height:10px; z-index:3"> 
  <table width="100%" border="1" align="center">
  <tr> 
  <td bgcolor="#005381"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>© 
  2009 P_zaN v Mat_PiH @ UPSI</strong></font></div></td>
  </tr>
  </table>
</div>
<div id="Layer5" style="position:absolute; left:147px; top:84px; width:234px; height:75px; z-index:5"> 
  <table width="101%" border="1">
  <tr> 
  <td width="18%" bordercolor="#FFFFCC" bgcolor="#005381"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Rekod Kaunseling</strong></font></div></td>
  </tr>
  <tr> 
  <td width="18%" bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"> 
  <div id="menu"> 
  <dt ><a href="rekodindividu.php" target="mainFrame"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Rekod Individu</font></a></dt>
  </div>
  </div></td>
  </tr>
  <tr> 
  <td width="18%" bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"> 
  <div id="menu"> 
  <dt ><a href="rekodkelompok.php" target="mainFrame"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Rekod Kelompok</font></a></dt>
  </div>
  </div></td>
  </tr>
 <tr> 
  <td width="18%" bordercolor="#FFFFCC" bgcolor="#FEF6E2"><div align="center"> 
  <div id="menu"> 
  <dt ><a href="laporan.php" target="mainFrame"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Laporan</font></a></dt>
  </div>
  </div></td>
  </tr>
  </table>
</div>
<div id="Layer6" style="position:absolute; left:146px; top:396px; width:247px; height:30px; z-index:6">
 
</div>
</body>
</html> |
|
|
|
|
|
|
|
kalau ko nak cari multiple No KP (dlm form ko)
dlm page rekodkelompok.php Line 83
- <input name="button" type="button" value="Tambah No KP" onClick="addRow(0);" />
Copy the Code
nak view balik apa yg ko post
- $no_kp = "";
- for($i=0;$i<count($_POST['filename']);$i++)
- {
- $no_kp.= $_POST['filename'][$i] .", ";
- }
- echo $no_kp;
Copy the Code
utk insert lak, page rekodkelompok2.php Line 105
- for($i=0;$i<count($_POST['filename']);$i++)
- {
- $sql = "INSERT INTO rekodkelompok (nokp,nokp2,tarikh,catatan,tindakan) values ('".mysql_real_escape_string(stripslashes($_POST['filename'][$i]))."','$nokp2','".mysql_real_escape_string(stripslashes($_REQUEST['tarikh']))."' ,'".mysql_real_escape_string(stripslashes($_REQUEST['catatan']))."' ,'".mysql_real_escape_string(stripslashes($_REQUEST['tindakan']))."' )";
- $result = mysql_query($sql ,$db)
Copy the Code |
|
|
|
|
|
|
|
tq boardmanager..
[ Last edited by pzan213 at 11-2-2009 11:25 AM ] |
|
|
|
|
|
|
|
board....sini aku ader script utk tarikh n hari yg dlm malay punye..cane ek kalo nak paparkan dlm textfield..sbb aku nak simpan dlm db..
<script type="text/javascript" ><!-- 
  var DayOfWeek = new Array('Ahad','Isnin','Selasa','Rabu','Khamis','Jumaat','Sabtu');
  var MonthName = new Array('Januari','Februari','Mac','April','Mei','Jun','Julai','Ogos','September',
  'Oktober','November','Disember');
  var theDate = new Date();
  document.write('<NOBR>' + '<font size="2" face="Verdana, Arial, Helvetica, sans-serif">' +
  DayOfWeek[theDate.getDay()] + ', ' +
  MonthName[theDate.getMonth()] + ' ' +
  theDate.getDate() + ', ' +
  (theDate.getYear() < 200 ? theDate.getYear() + 1900 : theDate.getYear()) +
  '</font></NOBR>');
  //--> </script>
[ Last edited by pzan213 at 12-2-2009 01:23 AM ] |
|
|
|
|
|
|
|
- <script type="text/javascript" ><!--
- var DayOfWeek = new Array('Ahad','Isnin','Selasa','Rabu','Khamis','Jumaat','Sabtu');
- var MonthName = new Array('Januari','Februari','Mac','April','Mei','Jun','Julai','Ogos','September',
- 'Oktober','November','Disember');
- var theDate = new Date();
- document.write('<input type="text" value="'+
- DayOfWeek[theDate.getDay()] + ', ' +
- MonthName[theDate.getMonth()] + ' ' +
- theDate.getDate() + ', ' +
- (theDate.getYear() < 200 ? theDate.getYear() + 1900 : theDate.getYear()) +
- '"/>');
- //-->
- </script>
Copy the Code |
|
|
|
|
|
|
|
tq |
|
|
|
|
|
|
|
Ni simple punya masalah..
Mesti celah gigi boardmanager aja masalah camni.
Aku ada table cam ni:
Name Subject Mark Grade Attendance
Abu English 40 B 99
Abu Matematik 44 B 89
Abu Fizik 80 A 90
Kassim English 75 A 91
Kassim Matematik 77 A 90
Baba English 12 F 48
Babuci English 55 D 89
Babuci Matematik 77 B 78
dan seterusnya lah lebih kurang
Aku nak buat report dalam bentuk cam ni:
English Matematik Fizik
Mark Grade Attendance | Mark Grade Attendance | Mark Grade Attendance
Abu 40 B 99 44 B 89 80 A 90
Kassim 75 A 91 77 A 90 - - -
Baba 12 F 48 - - - - - -
Babuci 55 D 89 77 B 78 - - -
Camna ya?
Tq |
|
|
|
|
|
|
|
soory lambat balas... bz
- $conn=mysql_connect($host,$user,$passwd) or die(mysql_error());
- $link=mysql_select_db($db,$conn) or die(mysql_error());
- $sql = "SELECT subject FROM student GROUP BY subject";
- $query = mysql_query($sql);
- while($row=mysql_fetch_assoc($query)){
- $subject[] = $row['subject'];
- }
- $sql = "SELECT name FROM student GROUP BY name";
- $query = mysql_query($sql);
- ?>
- <table border="1">
- <tr>
- <td>Name</td>
- <? for($i=0;$i<count($subject);$i++){ ?>
- <td><div><?= $subject[$i] ?></div>Mark|Grade|Attandance</td>
- <? } ?>
- </tr>
- <? while($row=mysql_fetch_assoc($query)){ ?>
- <tr>
- <td><?= $row['name'] ?></td>
- <?
- for($j=0;$j<count($subject);$j++){
- $sql2="SELECT * FROM student WHERE name = '".$row['name']."' AND subject = '". $subject[$j] ."'";
- $query2 = mysql_query($sql2);
- while($row2=mysql_fetch_assoc($query2)){
- ?>
- <td><?= $row2['mark'].'|'.$row2['grade'].'|'.$row2['attandance'] ?></td>
- <? }} ?>
- </tr>
- <? } ?>
- </table>
Copy the Code
ini data
- CREATE TABLE IF NOT EXISTS `student` (
- `student_id` int(5) NOT NULL auto_increment,
- `name` varchar(20) default NULL,
- `subject` varchar(20) default NULL,
- `mark` int(4) default NULL,
- `grade` varchar(4) default NULL,
- `attandance` int(4) default NULL,
- PRIMARY KEY (`student_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
- --
- -- Dumping data for table `student`
- --
- INSERT INTO `student` (`student_id`, `name`, `subject`, `mark`, `grade`, `attandance`) VALUES
- (1, 'Abu', 'English', 40, 'B', 99),
- (2, 'Abu', 'Matematik', 44, 'B', 89),
- (3, 'Abu', 'Fizik', 80, 'A', 90),
- (4, 'Kassim', 'English', 75, 'A', 91),
- (5, 'Kassim', 'Matematik', 77, 'A', 90),
- (6, 'Baba', 'English', 12, 'F', 48),
- (7, 'Babuci', 'English', 55, 'D', 89),
- (8, 'Babuci', 'Matematik', 77, 'B', 78);
Copy the Code |
|
|
|
|
|
|
|
Thanks Mr Boadmanager
Dah try tapi dapat table cam kat bawah ni:
Name English Fizik Matematik
Mark|Grade|Attandance Mark|Grade|Attandance Mark|Grade|Attandance
Abu 40|B|99 80|A|90 44|B|89
Baba 12|F|48
Babuci 55|D|89 77|B|78
Kassim 75|A|91 77|A|90
Markah matematik Kassim dan babuci pergi kat markah fizik pulak .. Babuci n Kassim tak amik pun Fizik. Camna ya?
Dan sebenarnya, aku nak Mark|grade|attendance tu dalam bentuk cell gak.. makna dalam bentuk table...
[ Last edited by sadiq_segaraga at 1-3-2009 12:24 AM ] |
|
|
|
|
|
|
|
boardmanager..long time no see...nape aku xdpt paparkan ek count nie..
$sql = "SELECT COUNT (sesi) FROM rekodindividu AS total WHERE nokp = '$nokp' ";
ni code dier
<?php
                        $nokp=$_POST['nokp'];
                       
                        $con = mysql_connect("localhost","root","1234");
                        if (!$con)
                          {
                                  die('Could not connect: ' . mysql_error());
                          }
  
                        mysql_select_db("nurani", $con);
                                                                       
                        $sql = "SELECT * FROM pelajar WHERE nokp = '$nokp' ";
                        $result = mysql_query($sql) or die("SQL select statement failed");
                        while ($row = mysql_fetch_array($result))  {
                        $nama=$row["nama"];
                        $tingkatan=$row["tingkatan"];
                        }
                                              
                        $sql = "SELECT COUNT (sesi) FROM rekodindividu AS total WHERE nokp = '$nokp' ";
                                                                          
                        ?>       
<? echo $row['total'];  ?> |
|
|
|
|
|
|
|
ko kena buat macam n
$sql = "SELECT COUNT(sesi) FROM rekodindividu AS total WHERE nokp = '$nokp' ";
$result = mysql_query($sql) or die("SQL select statement failed");
if($row = mysql_fetch_array($result))
echo $row['COUNT(sesi)'];
atau
$sql = "SELECT COUNT(sesi) AS total FROM rekodindividu AS total WHERE nokp = '$nokp' ";
$result = mysql_query($sql) or die("SQL select statement failed");
if($row = mysql_fetch_array($result))
echo $row['total']; |
|
|
|
|
|
|
|
ni untuk table yg ada cell
- $conn = mysql_connect($host, $user, $passwd) or die(mysql_error());
- $link = mysql_select_db($db, $conn) or die(mysql_error());
- $sql = "SELECT subject FROM student GROUP BY subject";
- $query = mysql_query($sql);
- while($row=mysql_fetch_assoc($query)){
- $subject[] = $row['subject'];
- }
- $sql = "SELECT name FROM student GROUP BY name";
- $query = mysql_query($sql);
- ?>
- <table border="1">
- <tr>
- <td rowspan="2">Name</td>
- <? for($i=0;$i<count($subject);$i++){ ?>
- <td colspan="3" align="center"><?= $subject[$i] ?></td>
- <? } ?>
- </tr>
- <? for($i=0;$i<count($subject);$i++){ ?>
- <td>Mark</td>
- <td>Grade</td>
- <td>Attandance</td>
- <? } ?>
- <? while($row=mysql_fetch_assoc($query)){ ?>
- <tr align="center">
- <td align="left"><?= $row['name'] ?></td>
- <?
- for($j=0;$j<count($subject);$j++){
- $sql2="SELECT * FROM student WHERE name = '".$row['name']."' AND subject = '". $subject[$j] ."'";
- $query2 = mysql_query($sql2);
- if($row2=mysql_fetch_assoc($query2)){
- echo '<td>'.$row2['mark'].'</td><td>'.$row2['grade'].'</td><td>'.$row2['attandance'].'</td>';
- }else{
- echo '<td> </td><td> </td><td> </td>';
- }}
- ?>
- </tr>
- <? } ?>
- </table>
Copy the Code |
|
|
|
|
|
|
| |
|