View: 3585|Reply: 16
|
PHP looping-Tolong..info yang ditaip taknak kluar ke browser
[Copy link]
|
|
Post Last Edit by mosti at 11-11-2010 14:47
Aku xtau mane silap nya, tapi asik kuar output(sepatutnya '$name','$comment' tu semua x keluar,patut kuar ape yang kite type)-->
Thank you, $name, for the following comments:
$commentWe will reply to you at$email \n"?>
==========================================
------------------|
form.html |
------------------|
<!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=utf-8" />
<title>Simple HTML form</title>
</head>
<body>
<!-- Script 2.1 - form.html -->
<form action="handle_form2.php" method="post">
<fieldset><legend>Enter your information in the form below:</legend>
<p><b>Name:</b><input type="text" name="name" size="20" maxlength="40"/></p>
<p><b>Email Address:</b><input type="text" name="email" size="40" maxlength="60"/></p>
<p><b>Gender:</b><input type="radio" name="gender" value="M"/>Male <input type="radio" name="gender" value="F"/>Female</p>
<p><b>Age:</b>
<Select name="age">
<option value="0-29">Under 30</option>
<option value="30-60">Between 30 and 60</option>
<option value="60+">Over 60</option>
</Select></p>
<p><b>Comments:</b><textarea name="comments" rows="3" cols="40"></textarea></p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit My information" /></div>
</form>
</body>
</html>
---------------------|
handle_form2.php|
---------------------|
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php #Script 2.2 - handle_form2.php
// Create a shorthand for the form data
$name= $_REQUEST['name'];
$email= $_REQUEST['email'];
$comments= $_REQUEST['comments'];
//Print the submitted info
echo "<p>Thank you, <b>$name</b>, for the following comments:<br /><tt>$comment</tt></p><p>We will reply to you at<i>$email</i></p>\n";
?>
</body>
</html> |
|
|
|
|
|
|
|
try mcm n- <!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=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body>
- <?php #Script 2.2 - handle_form2.php
- // Create a shorthand for the form data
- $name= $_REQUEST['name'];
- $email= $_REQUEST['email'];
- $comments= $_REQUEST['comments'];
- //Print the submitted info
- ?>
- <p>Thank you, <b><?= $name ?></b>, for the following comments:<br /><tt><?= $comment ?></tt></p><p>We will reply to you at<i><?= $email ?></i></p>
- </body>
- </html>
Copy the Code atau- <!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=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body>
- <?php #Script 2.2 - handle_form2.php
- // Create a shorthand for the form data
- $name= $_REQUEST['name'];
- $email= $_REQUEST['email'];
- $comments= $_REQUEST['comments'];
- //Print the submitted info
- echo "<p>Thank you, <b>". $name ."</b>, for the following comments:<br /><tt>". $comment ."</tt></p><p>We will reply to you at<i>". $email ."</i></p>\n";
- ?>
- </body>
- </html>
Copy the Code |
|
|
|
|
|
|
|
Reply 2# BorderManager
dua-dua x jalan..naik pening kepala aku..kejap boleh kuar output,tapi bile dah lama-lama ,x kuar pulak output tu. |
|
|
|
|
|
|
|
hmm...dalam explorer boleh kuar output pulak.hmmmm |
|
|
|
|
|
|
|
<!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=utf-8" />
<title>Register</title>
</head>
<body>
<!-- Script 6.1 -register.html-->
<p>Please complete this form to register:</p>
<form action="handle_reg.php" method="post">
<p>Name:<input type="text" name="fullName" size="20" /></p>
<p>Email:<input type="text" name="email" size="20" /></p>
<p>Password:<input type="password" name="password" size="20" /></p>
<p>Confirm Password:<input type="password" name="confirm" size="20" /></p>
<p>Date of Birth: <select name="day"/></p>
</form>
</body>
</html>
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<!--handle_reg.php-->
<body>
<?php
$day=$_REQUEST['day'];
echo "<select name='day'>";
for($day=1;$day<=31;$day++){
echo"<option value=\'$day\'>$day</option>\n";
}
echo '</select>';
?>
</body>
</html>
Output:
Uploaded with ImageShack.us |
|
|
|
|
|
|
|
Post Last Edit by mosti at 11-11-2010 14:48
Reply 6# BorderManager
Problemnye sekarang ni pulak,macam mana nak masukkan array dan for loop dalam html dan php.. |
|
|
|
|
|
|
|
hmm aku dah boleh dapat kan...cuma skunk ni macam mana nak kasi die nombor2 tu ke bawah bile pull-down.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Register</title>
</head>
<body>
<!-- Script 6.1 -register.html-->
<p>Please complete this form to register:</p>
<form action="handle_reg.php" method="post">
<p>Name:<input type="text" name="fullName" size="20" /></p>
<p>Email:<input type="text" name="email" size="20" /></p>
<p>Password:<input type="password" name="password" size="20" /></p>
<p>Confirm Password:<input type="password" name="confirm" size="20" /></p>
<p>Date of Birth: <select name="day"/></p>
<?php
for($day=1;$day<=31;$day++){
echo"<option value=\'$day\'>$day</option>\n";
}
?>
</select>
</form>
</body>
</html>
Output dibrowser:
|
|
|
|
|
|
|
|
cuba browse page tu guna mozilla.. |
|
|
|
|
|
|
|
Reply 10# ana_una
mozilla lansung tak kluar. |
|
|
|
|
|
|
|
Reply 10# ana_una
tadi try bukak mozilla boleh la pulak...tapi dalam explorer die naik ke atas lak..hmmm...pelik-pelik.
Yang sebelum2 ni,dalam mozilla tak nak keluar lansung. |
|
|
|
|
|
|
|
Nak mintak tolong pakar2 php... skang tgh buat sistem menilai penceramah, sy buat satu jer table... tapi nak kuarkan table tue banyak base pada braper banyak penceramah tu ada dlm sesuatu kursus.. tp yang keluar sekarang hanya satu jer.. contoh kdong saya:
<?php require_once "conn.php";
session_start();
?>
<?php
$tahun=$_GET['tahun'];
$nKursus = $_GET['nKursus'];
$sqlLaporan = "SELECT maklumatkursus.*,kursus.NAMAKURSUS,gred.gredkump,penyelaras.NAMAPENYELARAS FROM `maklumatkursus`,kursus,gred,penyelaras WHERE maklumatkursus.kodkursus=kursus.kodkursus and kursus.kodgred=gred.kodgred and maklumatkursus.KODPENYELARAS=penyelaras.KODPENYELARAS and maklumatkursus.ID ='$nKursus' ";
$rsltLaporan = mysql_query($sqlLaporan);
$rowLaporan = mysql_fetch_array($rsltLaporan);
$idKiraan=$rowLaporan['KODKURSUS'];
$sqlPeserta="SELECT * FROM `tblmain` WHERE kodkursus='$idKiraan' group by idpengguna";
$rsltPeserta = mysql_query($sqlPeserta);
$rowPeserta= mysql_num_rows($rsltPeserta);
$sqlKiraan="SELECT tblmain.kodkursus,tblmain.Topik,tblmain.penceramah,tblmain.value,count( tblmain.value ) AS jum_value, lookup_soalan.keterangan, tblmain.penceramah
FROM `tblmain`,lookup_soalan
WHERE tblmain.item = lookup_soalan.item
AND kodkursus = '112096'
GROUP BY topik, penceramah
";
$rsltKiraan = mysql_query($sqlKiraan);
$rowKiraan = mysql_query(rslKiraan);
$SSMula = $rowLaporan ['TARIKHMULA'];
list ($y, $m, $d) = explode ('-', $SSMula);
$TrkMula ="$d-$m-$y";
$SSAkhir1 = $rowLaporan ['TARIKHAKHIR'];
list ($y, $m, $d) = explode ('-', $SSAkhir1);
$TrkAkhir ="$d-$m-$y";
?>
<!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">
<script language="JavaScript">
function tdOver(obj) {
obj.style.backgroundColor ='pink';
obj.style.color='green';
}
function tdOut(obj) {
obj.style.backgroundColor ='';
obj.style.color='';
}
function kirakira()
{
//alert(parseInt(document.form1.Jpeserta.value)-parseInt(document.form1.jawab1.value));
document.form1.Tjawab.value=parseInt(document.form1.Jpeserta.value)-parseInt(document.form1.jawab1.value);
document.form1.a1.value=Math.round((parseInt(document.form1.jawab1.value)/ parseInt(document.form1.Jpeserta.value)* 100 )*100)/100 ;
document.form1.a1.value=document.form1.a1.value+' %';
document.form1.a2.value=Math.round((parseInt(document.form1.Tjawab.value)/ parseInt(document.form1.Jpeserta.value)* 100)*100)/100 ;
document.form1.a2.value=document.form1.a2.value+' %';
}
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-size: 20px;
font-weight: bold;
color: GREEN;
}
.style2 {
font-size: 13px;
font-weight: bold;
background-color:#CCCCCC;
font-family:Geneva, Arial, Helvetica, sans-serif;
}
.style3 {font-size: 12px;
font-family:Geneva, Arial, Helvetica, sans-serif;
}
.style4 {font-size: 12px;
font-weight: bold;
font-family:Geneva, Arial, Helvetica, sans-serif;
}
.style5
{
text-align:center;
font-size: 13px;
font-weight: bold;
background-color: #CCCCCC;
}
.style6
{
text-align:center;
font-size: 13px;
font-weight: bold;
}
-->
</style>
</head>
<body>
<form name="form1">
<br >
<div align="center" class="style1">LAPORAN PENILAIAN PENCERAMAH DALAM JABATAN BAGI
TAHUN <?php echo $tahun; ?> </div>
<br ><br >
<table width="816" border="0" cellspacing="1" cellpadding="1" align="center">
<tr>
<td height="28">NAMA KURSUS</td>
<td>:</td>
<td><strong><?php echo $rowLaporan ['NAMAKURSUS']; ?></strong></td>
</tr>
<tr>
<td width="312" height="28">KOD KURSUS</td>
<td width="10">:</td>
<td width="484"><strong>
<?php echo $rowLaporan ['KODKURSUS']; ?>
</strong></td>
</tr>
<tr>
<td height="28">TARIKH</td>
<td>:</td>
<td><strong>
<?php echo $TrkMula; ?>
hingga
<?php echo $TrkAkhir; ?>
</strong></td>
</tr>
<tr>
<td height="28">TEMPAT</td>
<td>:</td>
<td><strong>
<?php echo $rowLaporan ['TEMPAT']; ?>
</strong></td>
</tr>
<tr>
<td height="28">PENYELARAS</td>
<td>:</td>
<td><strong>
<?php echo $rowLaporan ['NAMAPENYELARAS']; ?><?php echo $rowKiraan ['penceramah']; ?></strong></td>
</tr>
<tr>
<td height="28">JUMLAH KESELURUHAN PESERTA</td>
<td>:</td>
<td>
<?php $bilTidakHadir = $rowLaporan['BILHADIR'] - $rowPeserta;
$peratusJawab = round(($rowPeserta / $rowLaporan['BILHADIR'] * 100 ) * 100) / 100;
$peratusTidakJawab = round(($bilTidakHadir / $rowLaporan['BILHADIR'] * 100 ) * 100) / 100;
?>
<strong>
<input type="text" name="Jpeserta" id="Jpeserta" size="2" maxlength="3" onkeyup="kirakira();" value="<?php echo $rowLaporan ['BILHADIR']; ?>" class="style5" readonly />
</strong></td>
</tr>
<tr>
<td height="28">BIL PESERTA YANG MENJAWAB</td>
<td>:</td>
<td> <strong> <input type="text" value="<?php echo $rowPeserta; ?>" name="jawab1" id="jawab1" size="2" class="style5" readonly />
<input type="text" name="a1" id="a1" size="5" class="style5" value="<?php echo $peratusJawab;?> <?php echo '%'?>" readonly />
</strong> </td>
</tr>
<tr>
<td height="28">BIL PESERTA YANG TIDAK MENJAWAB</td>
<td> </td>
<td>
<input type="text" name="Tjawab" id="Tjawab" size="2" class="style5" value="<?php echo $bilTidakHadir; ?>" readonly />
<input type="text" value="<?php echo $peratusTidakJawab;?> <?php echo '%'?>" name="a2" id="a2" size="5" class="style5" readonly /> </td>
</tr>
<tr>
<td height="28">KUMPULAN SASARAN</td>
<td>:</td>
<td><strong>
<?php echo $rowLaporan['gredkump']; ?>
</strong></td>
</tr>
</table>
<BR />
<p> </p>
<?php while($rowKiraan = mysql_fetch_array($rsltKiraan)) { ?>
<table width="100%" height="178" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#999999">
<tr>
<td height="27" colspan="24" class="style2"><p>Penceramah : <strong> <?php echo $rowKiraan ['penceramah']; ?></strong></p>
<p>Topik : <?php echo $rowKiraan ['Topik']; ?></p></td>
</tr>
<tr>
<td width="421" height="45" align="center" class="style2">SKALA</td>
<td width="42" align="center" class="style2"><div align="center">1</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="42" align="center" class="style2"><div align="center">2</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="42" align="center" class="style2"><div align="center">3</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="42" align="center" class="style2"><div align="center">4</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="42" align="center" class="style2"><div align="center">5</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="42" align="center" class="style2"><div align="center">6</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="42" align="center" class="style2"><div align="center">7</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="42" align="center" class="style2"><div align="center">8</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="42" align="center" class="style2"><div align="center">9</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="42" align="center" class="style2"><div align="center">10</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="76" class="style2"><div align="center">Tidak Berkaitan</div></td>
<td width="42" align="center" class="style2"><div align="center">%</div></td>
<td width="72" align="center" class="style2"><div align="center"> Berjawab</div></td>
</tr> |
|
|
|
|
|
|
|
yang ni pulak sambungannya...
<?php
$dd=array();
$i=1;
$sqlSoalan = "select lookup_soalan.keterangan from lookup_soalan,tblmain where tblmain.item=lookup_soalan.item and
tblmain.penceramah='".$rowKiraan['penceramah']."'and tblmain.Topik='".$rowKiraan['Topik']."'";
$rsltSoalan = mysql_query($sqlSoalan);
while($rowSoalan = mysql_fetch_array($rsltSoalan)){
$i=$i+1;
?>
<tr onmouseover="tdOver(this)" onmouseout="tdOut(this)">
<td height="35"><?php echo $rowSoalan['keterangan'];?></td>
<?php
$berjawab=0;
$ii=1;
for ($i=1;$i <= 23; $i++)
{
if($i%2){
if (mysql_num_rows($rsltKiraan)>1){
mysql_data_seek($rsltKiraan,0);
}
$rr=0;
while($clmtbl = mysql_fetch_array($rsltKiraan)){
if(trim($clmtbl["item"])==trim($rowSoalan["item"]) && $ii==$clmtbl["value"] ) {
$rr= $clmtbl["jum_value"];
$berjawab=$berjawab+$rr;
}
}
$tt=$dd[$ii];
$dd[$ii]=$tt+$rr;
$ii=$ii+1;
?>
<td class="style4"><div align="center">
<?php
if ($i==23){
echo $berjawab;
}
else
{
echo $rr;
}
?>
</div></td>
<?php
}else{
?>
<td class="style3"><div align="center">
<?php
if ($rr > 0)
echo round(($rr/$rowPeserta)*100,1).'%';
else
echo '0.0%';
?>
</div></td>
<?php
}
}
?>
</tr>
<?php
} ?>
<?php
} ?>
</table>
<p> </p>
<table width="700" border="0" cellspacing="1" cellpadding="1" align="center">
<tr>
<td width="281"> </td>
<td width="62"><input type="button" onClick="location.href='C_Laporan2.php'" value='Keluar'></td>
<td width="65"><input type=button onclick="window.print()" value='Cetak'> </td>
<td width="269"> </td>
</tr>
</table>
<div align="center"> </div>
</form>
</body>
</html>
** kedudukan while tue memang kene atas table kan.. plsss... dah buntu nak buat mcamana... |
|
|
|
|
|
|
|
wattapaakk. masuk dalam code weh. serabut tengok |
|
|
|
|
|
|
|
aku tak nampak mana satu yang tak keluar. tapi basicnya
- foreach ($penceramah as $a):
- //aku rasa sini kau guna table.
- penceramah: $a['nama']
- foreach($topikSetiapPenceramah as $b):
- topik: aaa
- skala: 1 | 2 | 3 | ... | 10
- endforeach;
- endforeach;
Copy the Code kau kene buat dua kali loop
1. untuk setiap penceramah
2. untuk setiap topik by penceramah |
|
|
|
|
|
|
|
aku tak nampak mana satu yang tak keluar. tapi basicnyakau kene buat dua kali loop
1. untuk setiap ...
kmkd Post at 2-6-2012 22:17
Hhehehehe.. sorri wehh.. aku yg beginner pun pening.. kene buat loop kat penceramah n topic tue eh..K2 akan kucuba buat seperti yang cikgu suruh.. tq2 |
|
|
|
|
|
|
| |
|