...

View Full Version : How get data and display on the listbox using php



deqnaz85
03-19-2009, 07:50 PM
Pleaaase help me to solve the problem...This is the code that I used but I still cannot get the data from the database using listbox...hope u understant mycode and help me to solve this .....:confused::confused:

<?php require_once('dbconnect.php'); ?>
<?php
mysql_select_db($dbname, $conn);
$query_profile = "SELECT program, name, semester, sesimasuk FROM student WHERE member_ID='$member_ID'";
$profile = mysql_query($query_profile, $conn) or die(mysql_error());
$row_profile = mysql_fetch_assoc($profile);
$totalRows_profile = mysql_num_rows($profile);

$sesi1="New";
mysql_select_db($dbname, $conn);
$query_sesi = "SELECT * FROM sesi WHERE status='$sesi1'";
$sesi = mysql_query($query_sesi, $conn) or die(mysql_error());
$row_sesi = mysql_fetch_assoc($sesi);
$totalRows_sesi = mysql_num_rows($sesi);
$pp=$row_profile['semester'];
mysql_select_db($dbname, $conn);
$query_Recordset1 = "SELECT * FROM program WHERE member_ID = '$member_ID' AND semester='$pp' ORDER BY kod_subjek ASC";
$Recordset1 = mysql_query($query_Recordset1, $conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$stat1="Mengulang";
?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>



-------------------------------------------------------------------------




<div id="layer" style="position:absolute; left:0px; top:49px; width:562px; height:400px; z-index:45">
<form name="form1" id="form1">
<table width="100%" height="273" border="0" class="tborder2">
<tr>
<td height="86"><table width="100%" height="81" border="0" class="tborder">
<tr class="tulisan4">
<td width="50%" height="25" bgcolor="#99CCFF"><p>Name : <? echo $name; ?>
<input name="name" type="hidden" id="name" value="<? echo $name; ?>" />
</p></td>
<td width="50%" bgcolor="#99CCFF">Semester :
<?
$sql="SELECT * FROM student WHERE member_ID='$member_ID'";
$result=mysql_query($sql);
$totalrow=mysql_num_rows($result);


$num = 0;
while ($num < $totalrow)
{
$vsem=mysql_result($result,$num,"semester");
$num++;
}
echo $vsem;
?> </td>
</tr>
<tr class="tulisan4">
<td height="23" bgcolor="#99CCFF">Matric : <? echo $member_ID; ?></td>
<td bgcolor="#99CCFF">Session Kemasukan :
<?
$sql="SELECT * FROM student WHERE member_ID='$member_ID'";
$result=mysql_query($sql);
$totalrow=mysql_num_rows($result);


$num = 0;
while ($num < $totalrow)
{
$vsesimasuk=mysql_result($result,$num,"sesimasuk");
$kodprogram=mysql_result($result,$num,"kodprogram");
$num++;
}
echo $vsesimasuk;
?> </td>
</tr>
<tr class="tulisan4">
<td height="23" bgcolor="#99CCFF">Program :
<?
$sql="SELECT * FROM student WHERE member_ID='$member_ID'";
$result=mysql_query($sql);
$totalrow=mysql_num_rows($result);


$num = 0;
while ($num < $totalrow)
{
$program=mysql_result($result,$num,"program");
$num++;
}
echo $program;
?> </td>
<td bgcolor="#99CCFF">Sesi :
<?
$test='New';
$sql="SELECT * FROM sesi WHERE status='$test'";
$result=mysql_query($sql);
$totalrow=mysql_num_rows($result);


$num = 0;
while ($num < $totalrow)
{
$vsesi=mysql_result($result,$num,"sesi");
echo "$vsesi";
$num++;
}
?>
<input name="member_ID" type="hidden" id="member_ID" value="<? echo $member_ID; ?>"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="36"><div align="center">
<p class="tulisan4">Choose subject from the list :</p>
<span class="tulisan4">
<select name="subjek2">
<?
//$quer=mysql_query("SELECT DISTINCT * WHERE kod_programme='$kod_programme' FROM subjeck ORDER BY semester ASC");
//"SELECT DISTINCT semester FROM program WHERE member_ID='$member_ID' ORDER BY semester ASC";

$query = "SELECT DISTINCT nama_subjek FROM subjeck FROM member_ID='$member_ID' ORDER BY semester ASC";
$result = mysql_query($query);
$row = mysql_num_rows($result);


$num=0;
while($num < $row){

$kod=mysql_result($result,$num,"kod_subjek");
$subjek1=mysql_result($result,$num,"nama_subjek");
$kl=mysql_result($result,$num,"prasyarat");
$hg="Gagal";

if($kl!=NULL){

$query1 = "SELECT kod_subjek,status_gred FROM program WHERE member_ID='$member_ID'
AND kod_subjek='$kl'";

$result1 = mysql_query($query1);
$row1 = mysql_fetch_array($result1);

if($row1){
$jj=$row1["kod_subjek"];
$pp=$row1["status_gred"];}

if(($jj!=$kl)||($pp=="Lulus"))
echo"<OPTION VALUE=\"$kod\">$kod - $subjek1 \n";}
else{
echo"<OPTION VALUE=\"$kod\">$kod - $subjek1 \n";
}

$num++;
}


?>
</select>
<input name="status" type="radio" value="New" checked="checked" />
New
<input name="butang" type="submit" id="butang" value="Add" />
<?
if(isset($butang)){

if($butang=="Add"){
//simpan dalam table program

$sql2="SELECT * FROM program WHERE member_ID='$member_ID' AND kod_subjek='$subjek2' AND sesi='$vsesi'";
$result2=mysql_query($sql2);

$num=0;
do
{
$kod_subjek=$totalrow2["kod_subjek"];
$sesi=$totalrow2["sesi"];
$num++;
}while($totalrow2=mysql_fetch_array($result2));

if(($kod_subjek==$subjek2)&&($sesi==$vsesi)){

echo"<script>"
." alert('Harap Maaf Subjek Sudah Wujud..');"
."</script>";
}
else{
$sql="SELECT * FROM subjeck WHERE kod_subjek='$subjek2'";
$result=mysql_query($sql);
$totalrow=mysql_fetch_array($result);


if($totalrow)
{
$subjek1=$totalrow["nama_subjek"];
$kredit=$totalrow["jam_kredit"];
}
$sql="INSERT INTO program(name,member_ID,semester,kod_subjek,jam_kredit,status_subjek,sesi,nama_subjek)
VALUES ('$name','$member_ID','$vsem','$subjek2','$kredit','$status','$vsesi','$subjek1')";
$result=mysql_query($sql);
if($result){
echo"<script>"
." alert('Record have been save');"
."location.href='registerCourseDcs.php?member_ID=$member_ID'"
."</script>";

}
}
}
}
?>
</span> </div></td>
</tr>
<tr>
<td height="108"><div align="center">&nbsp;
<table border="0" class="tborder">
<tr bgcolor="#006699" class="text2">
<td width="17" bgcolor="#000099"><div align="center" class="style4"><font size="2">Bil</font></div></td>
<td width="153" bgcolor="#000099"><div align="center" class="style4"><font size="2">Kod
Subjek</font></div></td>
<td width="271" bgcolor="#000099"><div align="center" class="style4"><font size="2">Nama
Subjek</font></div></td>
<td width="146" bgcolor="#000099"><div align="center" class="style4"><font size="2">Jam
Kredit</font></div></td>
<td width="163" bgcolor="#000099"><div align="center" class="style4"><font size="2">Status
Subjek</font></div></td>
<td width="48" bgcolor="#000099"><div align="center" class="style4"><font size="2">Operasi</font></div></td>
</tr>
<?php $num=0; do { ?>
<tr class="tulisan4" >
<input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>" />
<td><? echo $num+=1; ?>
<div align="center"></div></td>
<td align="center"><div align="center"><?php echo $kodla=$row_Recordset1['kod_subjek']; ?></div></td>
<td><div align="center"><?php echo $row_Recordset1['nama_subjek']; ?></div></td>
<td><div align="center"><?php echo $row_Recordset1['jam_kredit']; ?></div></td>
<td><div align="center">
<?php $status=$row_Recordset1['status_subjek'];
if ($status=="Mengulang"){
echo "Mengulang";
}
else
echo "New";
?>
</div></td>
<td bgcolor="#eff7ff" onmouseover="this.bgColor='#DCEBD6'" onmouseout="this.bgColor='#eff7ff'"><div align="center">
<?php $ggg=$row_Recordset1['gred'];if(($status=="Mengulang")||($ggg!=NULL)){ echo "Tiada";} else{ ?>
<a href="try.php?id=<?php echo $row_Recordset1['id'];?>&amp;member_ID=<?php echo $row_Recordset1['member_ID']; ?> ">Delete</a>
<? }?>
</div></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</div></td>
</tr>
</table>
</form>
<p>
<?

if(isset($gugur)){
/*
echo "<script>"
."if(confirm('Adakah Anda Pasti Untuk Gugurkan Subjek ni!!')){"
."location.href='try.php?matrik=$matrik&id=$id'}"
."else{ alert('Terima kasih...');"
."location.href='subjek1.php?matrik=$matrik'}"
."</script>";
*/
if ($gugur="Gugur"){
$tanya21="DELETE FROM program WHERE id='$id'";

$tanya12=mysql_query($tanya21);

if ($tanya12){
echo"<script>"
." alert('Rekod sudah dipadam!');"
."location.href='registerCourseDcs.php?member_ID=$member_ID'"
."</script>";
}
else echo "vfzxvxzv";
}
}
?>
</p>
<p align="center"><a href="viewRegisterSub.php?member_ID=<?php echo $_SESSION['myusername'];?>">View Subject</a><a href="viewRegisterSub.php?member_ID=<?php echo $row['member_ID'];?>"></a></p>
</div>

tomws
03-19-2009, 09:04 PM
What errors are you receiving? What's not working as expected?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum