LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-29-2007, 01:40 PM   #1
koscek
Member
 
Registered: May 2006
Distribution: Fedora 7
Posts: 34

Rep: Reputation: 15
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
 
Old 10-30-2007, 12:22 AM   #2
koscek
Member
 
Registered: May 2006
Distribution: Fedora 7
Posts: 34

Original Poster
Rep: Reputation: 15
someone please help me
 
Old 11-02-2007, 06:42 AM   #3
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wine fonts small dropdown list invisible in STELLA bristi Linux - Software 1 06-22-2005 06:07 AM
MySQL - Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 9 jasontn Linux - Software 0 02-09-2005 12:17 PM
problem transfering result of search to a dialog box JoannesX Programming 3 02-07-2005 05:59 AM
where is majorcool list dropdown facility pudhiyavan Linux - Software 1 06-09-2004 03:28 AM
mozilla session problem (did search could not find result) exodist Linux - Software 2 02-29-2004 04:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration