almystersv Posted January 25, 2008 Share Posted January 25, 2008 Hi Guys, Im doing a page that allows an administrator to allocate tasks to members of staff for the week ahead. I have pages that list the tasks that need to be done on a Monday, Tuesday.... and next to them I have drop down menus that list the employees in the database. But unfortunately the drop down menu only works for the first in the list and the remainder do not list the employees. I am also having trouble saving the information i.e. with the submit button. Here is my code for the page listing Mondays tasks <?php session_start(); if (isset($_SESSION['type']) == 'admin'){ header("Location: login.php"); exit(); } require "connect.php"; $query = "select * from task where weekday = 'Everyday' OR 'Monday' ORDER BY taskID"; $result = mysql_query($query, $connection) or die ("Unable to perform query $query"); $query2 = "select * from employee"; $result2 = mysql_query($query2, $connection) or die ("Unable to perform query $query2"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Task Allocation</title> <link rel="stylesheet" type="text/css" href="mystylelogin.css" /> </head> <body> <?php include ("headerAdmin.php"); ?> <h1>Task Allocation</h1> <p>Monday</p> <table width="860" > <hr /> <tr> <th width="142"><div align="left" class="style2">Task Name</div></th> <th width="262"><div align="left" class="style2">Description</div></th> <th width="140"><div align="left" class="style2">Weekday</div></th> <th width="140"><div align="left" class="style2">Assign</div></th> </tr> <?php while($row = mysql_fetch_array($result)) { ?> <tr> <td height="27"><?php echo $row['taskName']?></td> <td><?php echo $row['taskDescription']?></td> <td><?php echo $row['weekday']?></td> <td> <form action="taskAdminQuery.php"> <select name="empName"> <option>Select an Employee</option> <?php while ($row2 = mysql_fetch_array($result2)) { ?><option value"<?php echo $row['empID']?>"><?php echo $row2['fName']?> <?php echo $row2['sName']?></option> <?php } ?> </select></td> <td><input name="taskID" value="<?php echo $row['taskID']?>" /></td> </tr> <?php } ?> <input name="Save" type="submit" value="Allocate Tasks" /> </form> </table> <?php if(isset($_GET['message1'])) { echo $_GET['message1']; } ?> </body> </html> Here is the page that is running the query <?php require "connect.php"; $empID = $_GET['empName']; $emptaskweekDay = $_GET['weekday']; $taskID = $_GET['taskID']; $query = "insert into emptask values ('".$taskID."','".$empID."','".$emptaskweekDay."', 'N')"; $result = @mysql_query($query, $connection) or die ("Unable to perform query<br>$query"); header("Location: TaskAdmin.php"); $message1 = "Tasks Allocated Successfully."; header("Location: TaskAdmin.php?message1=$message1"); exit(); ?> Please help. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/87669-drop-down-menu-problems/ Share on other sites More sharing options...
Stooney Posted January 25, 2008 Share Posted January 25, 2008 Try adding semi-colons to the areas similar to: <?php echo $row['empID']?> so the new code would be: <?php echo $row['empID']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/87669-drop-down-menu-problems/#findComment-448446 Share on other sites More sharing options...
almystersv Posted January 25, 2008 Author Share Posted January 25, 2008 hi thanks, I've tried that and it hasn't made any difference. Just out of interest, what does adding the semi-colons do!? Quote Link to comment https://forums.phpfreaks.com/topic/87669-drop-down-menu-problems/#findComment-448737 Share on other sites More sharing options...
dg Posted January 25, 2008 Share Posted January 25, 2008 chnge this <option value"<?php echo $row['empID']?>"><?php echo $row2['fName']?> <?php echo $row2['sName']?></option> to <option value="<?php echo $row['empID']?>"><?php echo $row2['fName']?> <?php echo $row2['sName']?></option> Quote Link to comment https://forums.phpfreaks.com/topic/87669-drop-down-menu-problems/#findComment-448780 Share on other sites More sharing options...
almystersv Posted January 27, 2008 Author Share Posted January 27, 2008 Hi, I made that change and it hasn't changed anything either. I need all the drop down menus to read from the database rather than just the first one. Quote Link to comment https://forums.phpfreaks.com/topic/87669-drop-down-menu-problems/#findComment-450392 Share on other sites More sharing options...
almystersv Posted January 27, 2008 Author Share Posted January 27, 2008 anyone know to fix this...? Quote Link to comment https://forums.phpfreaks.com/topic/87669-drop-down-menu-problems/#findComment-450560 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.