Jump to content

combo box?


dyela

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

<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">

&nbsp

    <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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.