koscek Posted October 30, 2007 Share Posted October 30, 2007 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/75306-no-select-result-mysql-using-dropdown-list/ Share on other sites More sharing options...
teng84 Posted October 30, 2007 Share Posted October 30, 2007 dont use do while use only while loop the first option will be empty because nothing is fetch from your db Quote Link to comment https://forums.phpfreaks.com/topic/75306-no-select-result-mysql-using-dropdown-list/#findComment-380865 Share on other sites More sharing options...
koscek Posted October 30, 2007 Author Share Posted October 30, 2007 any solution? i'm stuck Quote Link to comment https://forums.phpfreaks.com/topic/75306-no-select-result-mysql-using-dropdown-list/#findComment-380871 Share on other sites More sharing options...
koscek Posted October 30, 2007 Author Share Posted October 30, 2007 someone please help me Quote Link to comment https://forums.phpfreaks.com/topic/75306-no-select-result-mysql-using-dropdown-list/#findComment-380922 Share on other sites More sharing options...
~n[EO]n~ Posted October 30, 2007 Share Posted October 30, 2007 teng told not to use do, so just try with while <?php while($array=mysql_fetch_array($result)){ ?> Quote Link to comment https://forums.phpfreaks.com/topic/75306-no-select-result-mysql-using-dropdown-list/#findComment-380932 Share on other sites More sharing options...
koscek Posted October 30, 2007 Author Share Posted October 30, 2007 how ? Quote Link to comment https://forums.phpfreaks.com/topic/75306-no-select-result-mysql-using-dropdown-list/#findComment-380971 Share on other sites More sharing options...
anujgarg Posted October 30, 2007 Share Posted October 30, 2007 koscek, i think you need to have a look on some tutorials for do-while and while loops Quote Link to comment https://forums.phpfreaks.com/topic/75306-no-select-result-mysql-using-dropdown-list/#findComment-380993 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.