LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Search result MYSQL using dropdown list (https://www.linuxquestions.org/questions/programming-9/search-result-mysql-using-dropdown-list-595545/)

koscek 10-29-2007 01:40 PM

Search result MYSQL using dropdown list
 
PHP Code:

 <?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>&nbsp; 

          <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($ListDept0);

      
$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">&nbsp;</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">&nbsp;</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>&nbsp;</td>

      <td>&nbsp;</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

koscek 10-30-2007 12:22 AM

someone please help me

Guttorm 11-02-2007 06:42 AM

Hi

I don't think it's possible to find a solution from what you posted. Do you get any error message when running on the Linux server?

Many newer Linux distros turn off PHP error reporting by default for security reasons. But you can look in Apache's error log to see if there is something. Another option is to add this somewhere in the beginning of your code:
PHP Code:

error_reporting(E_ALL); 

When something works on some platforms but not on others, it's usually because some setting in php.ini or that you are missing a PHP module.

Another problem is that filenames are case sensitive on Linux and not on Windows.

Anyway, an error message should give you a clue about the problem.


All times are GMT -5. The time now is 11:01 AM.