Jump to content

No select result MYSQL using dropdown list


koscek

Recommended Posts

<?php require_once('Connections/kioks.php'); ?>





<?php

mysql_select_db($database_kioks, $kioks);

$query_ListDept = "SELECT * FROM department";

$ListDept = mysql_query($query_ListDept, $kioks) or die(mysql_error());

$row_ListDept = mysql_fetch_assoc($ListDept);

$totalRows_ListDept = mysql_num_rows($ListDept);



$maxRows_ListLect = 10;

$pageNum_ListLect = 0;

if (isset($HTTP_GET_VARS['pageNum_ListLect'])) {

  $pageNum_ListLect = $HTTP_GET_VARS['pageNum_ListLect'];

}

$startRow_ListLect = $pageNum_ListLect * $maxRows_ListLect;



$colname_ListLect = "0";

if (isset($HTTP_POST_VARS['menu1'])) {

  $colname_ListLect = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['menu1'] : addslashes($HTTP_POST_VARS['menu1']);

}

mysql_select_db($database_kioks, $kioks);

$query_ListLect = sprintf("SELECT * FROM lecturer WHERE Department_Code = '%s' ORDER BY lecturer.Lecturer_Name", $colname_ListLect);

$query_limit_ListLect = sprintf("%s LIMIT %d, %d", $query_ListLect, $startRow_ListLect, $maxRows_ListLect);

$ListLect = mysql_query($query_limit_ListLect, $kioks) or die(mysql_error());

$row_ListLect = mysql_fetch_assoc($ListLect);



if (isset($HTTP_GET_VARS['totalRows_ListLect'])) {

  $totalRows_ListLect = $HTTP_GET_VARS['totalRows_ListLect'];

} else {

  $all_ListLect = mysql_query($query_ListLect);

  $totalRows_ListLect = mysql_num_rows($all_ListLect);

}

$totalPages_ListLect = ceil($totalRows_ListLect/$maxRows_ListLect)-1;



$colname_dept = "0";

if (isset($HTTP_POST_VARS['menu1'])) {

  $colname_dept = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['menu1'] : addslashes($HTTP_POST_VARS['menu1']);

}

mysql_select_db($database_kioks, $kioks);

$query_dept = sprintf("SELECT * FROM department WHERE Department_Code = '%s'", $colname_dept);

$dept = mysql_query($query_dept, $kioks) or die(mysql_error());

$row_dept = mysql_fetch_assoc($dept);

$totalRows_dept = mysql_num_rows($dept);

?>

<html>

<head>

<title>Lecturer Info</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



</head>



<body bgcolor="82ccdc">



<table bgcolor="#c5edf5"  width="43%" height="363" align="center" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">

  <form name="dept" action="" method="post">

   <tr>

    <td valign="top">

            <tr> 

          <td height="18" valign="top">

            <?php include 'includes/header.php'; ?>

          </td>

        </tr> 

      <tr valign="top"> 

      <td><hr class=lineBlack></td>

    </tr>

    <tr>

      <td height="44" align="center">

<p><font size="2" color="#286370"><strong>  

          <label>Please select department</label>

          </strong>

          <label></label>

          </font>

          <label></label>

        </p>

        <p> 

          <select name="menu1" id="menu1" onChange="dept.submit();">

            <option value="">Select Department</option>

            <?php

do {  

?>

            <option value="<?php echo $row_ListDept['Department_Code']?>"><?php echo $row_ListDept['Deparment_Description']?></option>

            <?php

} while ($row_ListDept = mysql_fetch_assoc($ListDept));

  $rows = mysql_num_rows($ListDept);

  if($rows > 0) {

      mysql_data_seek($ListDept, 0);

      $row_ListDept = mysql_fetch_assoc($ListDept);

  }

?>

          </select>

        </p>

        </td>

    </tr>

  

</form>

<form method="get">

<tr>

<td>

  <table width="100%" height="100%" align="center" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">

          <?php if ($totalRows_dept > 0) { // Show if recordset not empty ?>

    <tr> 

      <td><strong><font color="#286370" size="2">Department</font></strong></td>

            <td colspan="2"><font color="#286370" size="2"> 

              <?php echo $row_dept['Deparment_Description']; ?></font></td>

    </tr>

    <?php } // ?>

    

    <tr> 

            <td colspan="3"> </td>

    </tr>

    <?php if ($totalRows_ListLect > 0) { // Show if recordset not empty ?>

    <tr> 

            <td width="43%" height="17" bgcolor="82ccdc">

<div align="left"><font color="#286370" size="2"><strong>Name</strong></font></div></td>

      <td width="29%" bgcolor="82ccdc"><div align="left"><font color="#286370" size="2"><strong>Ext</strong></font></div></td>

      <td width="25%" bgcolor="82ccdc"><div align="left"><font color="#286370" size="2"><strong>Room 

          No.</strong></font></div></td>

    </tr>

    <tr>

            <td height="23" colspan="3"> </td>

          </tr>

    <?php do { ?>

    <tr> 

      <td><strong><font color="#286370" size="2"><a href="LecturerInfo.php?id=<?php echo $row_ListLect['Lecturer_ID']; ?>"><?php echo $row_ListLect['Lecturer_Name']; ?> </a> </font></strong></td>

      <td> </td>

      <td> </td>

    </tr>

    <?php } while ($row_ListLect = mysql_fetch_assoc($ListLect)); ?>

    <tr> 

            <td colspan="3" align="left" bgcolor="82ccdc"><font color="#286370" size="2"><strong> 

              Previous || Next </strong></font></td>

    </tr>

    <?php } // Show if recordset not empty ?> 

  </table>

</form>

</td>

</tr>

</table>

</body>

</html>

<?php

mysql_free_result($ListLect);



mysql_free_result($ListDept);



//mysql_free_result($ListLect);



mysql_free_result($dept);

?>

 

i have this code. when i add into windows apache server its running great....but not in linux(fedora7) apache server... why?

 

when i select the choice from the drop down box...the list in drop down box is get from mysql,here is no problem....but there nothing output/result, which is from mysql

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.