dyela Posted May 10, 2007 Share Posted May 10, 2007 how to make combo box link with my database? I want my data appear when drag down the combo box Can someone help me with the code i should use??? Link to comment https://forums.phpfreaks.com/topic/50768-combo-box/ Share on other sites More sharing options...
mmarif4u Posted May 10, 2007 Share Posted May 10, 2007 I think we meet in the prev post ok the below is the code which u can change according tour requirements. <select name="name" class="selectBlue"> <?php $sql="select * from tablename"; $result = mysql_query($sql) or die(mysql_error()); while($row= mysql_fetch_array($result)){ echo "<option value='{$row->userid}'>{$row->username}</option>"; } ?></select> Link to comment https://forums.phpfreaks.com/topic/50768-combo-box/#findComment-249587 Share on other sites More sharing options...
roopurt18 Posted May 10, 2007 Share Posted May 10, 2007 A combo box is a different entity than a select control. I'm fairly certain there is no built-in support for them and that you'd have to create your own control using an input[type=text] in combination with a select and a fair amount of Javascript. If you're just wanting page elements to change as a user selects different items in a regular select box, you're in the wrong forum as you'll need to use Javascript. Link to comment https://forums.phpfreaks.com/topic/50768-combo-box/#findComment-249589 Share on other sites More sharing options...
dyela Posted May 10, 2007 Author Share Posted May 10, 2007 thanks.. but now i want to know about this coding... if (!mysql_num_rows($result)) { echo "<script languange = 'Javascript'> alert ('Harap maaf'); location.href='bar_code.php'; </SCRIPT>"; } else { } somebody help me.. Link to comment https://forums.phpfreaks.com/topic/50768-combo-box/#findComment-249604 Share on other sites More sharing options...
mmarif4u Posted May 10, 2007 Share Posted May 10, 2007 thanks.. but now i want to know about this coding... if (!mysql_num_rows($result)) { echo "<script languange = 'Javascript'> alert ('Harap maaf'); location.href='bar_code.php'; </SCRIPT>"; } else { } somebody help me.. mysql_num_rows shows the number of rows from the table, and ! mean no, so ur script mean that if there is no row from table go to message and then bar_code.php Link to comment https://forums.phpfreaks.com/topic/50768-combo-box/#findComment-249608 Share on other sites More sharing options...
dyela Posted May 10, 2007 Author Share Posted May 10, 2007 <HTML> <HEAD> <TITLE>Maklumat terperinci pelajar</TITLE> </HEAD> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #0092C1; font-weight: bold; } .style6 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #CC6600; font-weight: bold; } .style2 {color: #CC6600} .style7 {color: #000000} --> a, A:link, a:visited, a:active, A:hover { color: #0000ff; text-decoration:none; font-family:Verdana, Arial, Helvetica, sans-serif; font-size: 11 px} .style9 {font-size: 10px; color: #0092C1; font-family: Verdana, Arial, Helvetica, sans-serif;} body { background-color: #F8F8F8; } </style> <? include ("mysql.php"); $string = date("Y-m-d"); /* //$id=$_POST['id']; $q1 = "select * from insert_pelatih_keluar where dateout ='$string'"; $r1=mysql_query($q1); //use of fetch array while($row=mysql_fetch_array($r1)){ $id=$row["id"]; $masakeluar=$row["timeout"]; $tujuan=$row["tujuan"]; $butiran=$row["butiran"]; } //echo "<tr><td><a href=display.php?id=$id>Daftar Pelatih</a></td><td>$nama</td> <td>$nodaftar</td><td>$kursus</td></tr>"; $q = "select * from daftar_pelatih where id='$id'"; $r=mysql_query($q); //use of fetch array $row=mysql_fetch_array($r); $nama=$row["nama"]; //if(mysql_error()){echo mysql_error();} $id=$row["id"]; $nodaftar=$row["no_daftar"]; $kursus=$row["kod_kursus"]; */ ?> <body> <form method="POST" action="display.php"> <TABLE style="border-style:solid; border-color:#666666; background:#E0E0E0; " width="699" border="2" > <TR> <TD>Sila masukkan maklumat anda di bawah</TD> <tr></tr> </TR> <TD>No matrik : <input type="text" name="no_daftar" size="20"></TD> <TR> <TD><input type="submit" name="cari" value="Cari"></TD> </TR> </p> </form> <form> <TABLE style="border-style:solid; border-color:#666666; background:#E0E0E0; " width="699" border="2">   <TR>Senarai pelajar yang keluar pada hari ini </TR> <tr> <TD>Nama Pelajar</TD> <TD>No Matrik</TD> <TD>Kod Kursus</TD> <TD>Masa Keluar</TD> <TD>Tujuan</TD> <TD>Butiran</TD> </tr> <? $q1 = "select * from insert_pelatih_keluar where dateout ='$string'"; $r1=mysql_query($q1); //use of fetch array while($row=mysql_fetch_array($r1)){ $id=$row["id"]; $masakeluar=$row["timeout"]; $tujuan=$row["tujuan"]; $butiran=$row["butiran"]; $q2 = "select * from daftar_pelatih where id='$id'"; $r2=mysql_query($q2); //use of fetch array $row2=mysql_fetch_array($r2); $nama=$row2["nama"]; $nodaftar=$row2["no_daftar"]; $kursus=$row2["kod_kursus"]; echo "<tr><td>$nama</td><td>$nodaftar</td><td>$kursus</td><td>$masakeluar</td><td>$tujuan</td><td>$butiran</td></tr>"; } ?> </table> </form> </body> <a href="laporankeluar.php">Lihat Laporan</a> this is my project coding.. so where i must put this coding if (!mysql_num_rows($result)) { echo "<script languange = 'Javascript'> alert ('Harap maaf'); location.href='bar_code.php'; </SCRIPT>"; } else { } Link to comment https://forums.phpfreaks.com/topic/50768-combo-box/#findComment-249616 Share on other sites More sharing options...
mmarif4u Posted May 10, 2007 Share Posted May 10, 2007 1st u have to mention ur num_rows from db then u have to use, but i am not sure where u want to stop the code and then redirect to this page.i mean after $q1 or $q2. if $q1 then put it after ur query if $q2 then put it after q2 query. $num=mysql_num_rows($q1); if (!$num){ echo "<script languange = 'Javascript'> alert ('Harap maaf'); location.href='bar_code.php'; </SCRIPT>"; } else { } Link to comment https://forums.phpfreaks.com/topic/50768-combo-box/#findComment-249623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.