Jump to content

will2002

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by will2002

  1. Sorry forgot to add the code <html> <body> <table border="2" bgcolor="#3399FF" cellpadding="1" cellspacing="1"> <form name='form1' method='post' action='formloop.php'> <input type='submit' name='save' value='Submit'> <?php $a=0; while ($a <= "2"){ echo"<tr><td><input type='text' name='enum'></td> <td><input type='text' name='ename' size='2'></td> <td><input type='text' name='time'></td> <td><input type='text' name='timehalf'></td> <td colspan='0' align = center> </td> </tr>"; $a++; } ini_set('display_errors', 1); error_reporting(E_ALL & ~E_NOTICE); if(isset($_POST['save'])){ if($dbc = @mysql_connect('localhost', '', '')){ if(!$dbc = @mysql_select_db('employees')){ die("<p> Could not select the database because:'.mysql_error().'</p>"); } } $b=0; while ($b <= "2"){ $query = "INSERT INTO timesheet (num, name, norm, normhalf) VALUES ('{$_POST['enum']}', '{$_POST['ename']}', '{$_POST['time']}', '{$_POST['timehalf']}'"; $b++; if(@mysql_query ($query)){ print "<p align='center'>The timesheet has been saved</p>"; } else{ print"<p align='center'>Sorry. Unable to save details.</p>"; } } } ?> </form> </table> </body> </html>
  2. Below is some code showing the basic layout of what im trying to do. once the button is pressed the while loop should continue to run the insert query until all the rows are done ie 3 rows in the sample code below. I know there is extra code needed to get the sql query to continually run within the while loop but im not really sure what to include. I may be dooing it totally wrong so im open to any suggestions
  3. Hi I am developing an application that stores weekly working hours for employees. i currently have a form which takes in an employees timesheet and saves it to a database. The problem is that the form i have created only allows one employee entry to be submitted at a time. I need to be able to enter rows of employee data for all employees the same as you would in an excel spreadsheet and have the submit button enter the entire form with all the employees data. i am assuming it would probably involve an array and a for or while loop to run through the rows but im not really sure how to go about it. Im not asking anyone to do it for me just a nudge in the right direction. thanks in advance.
  4. hi I have an sql query which prints output to a html form. i then use header code to save the results of this as a microsoft excel document. All of the code is working fine. The only problem is that everything on the page is being saved in the excel file such as images, search fields, buttons etc. is there a way to just take the information from the query without the rest of the page coming aswell any help would be greatly appreciated. here is the section of code minus the html form and html table data, there is a lot of html code on the full page for navigation and visual purposes. hi I have an sql query which prints output to a html form. i wish to be able to send the results of this to a microsoft excel document. All of the code is working fine. The only problem is that everything on the page is being saved in the excel file such as images, search fields, buttons etc. is there a way to just take the information from the query without the rest of the page coming aswell any help would be greatly appreciated. here is the section of code minus the html form and html table data, there is a lot of html code on the full page for navigation and visual purposes. <?php ini_set('display_errors', 1); error_reporting(E_ALL & ~E_NOTICE); if(isset($_POST['login'])){ if($dbc = @mysql_connect('localhost', '', '')){ if(!$dbc = @mysql_select_db('employees')){ die("<p> Could not select the database because:'.mysql_error().'</p>"); } }else{ die("<p> Could not select the database because:'.mysql_error().'</p>"); } $query = "SELECT * FROM timesheet WHERE day='{$_POST['dt']}' AND month='{$_POST['month']}'AND year='{$_POST['year']}'"; if ($r = mysql_query($query)){ while ($row =mysql_fetch_array($r)){ echo "<tr><td>{$row['num']}</td><td>{$row['name']}</td><td>{$row['norm']}</td><td>{$row['normhalf']}</td><td>{$row['normdouble']}</td><td>{$row['normquarter']}</td><td>{$row['normthird']}</td><td>{$row['hol']}</td><td>{$row['hol1']}</td><td>{$row['hol2']}</td><td>{$row['hol3']}</td><td>{$row['remarks']}</td></tr>"; header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition:filename=file.xls"); ob_end_flush(); ?>
  5. I have figured it out. Just going to use two tables as you said. thanks for the help
  6. Thanks for the replies The employees work on a building site and have no access to a computer. They complete a timesheet each week and hand it into the office so i guess wrathican your suggestion wouldnt work for this situation thanks for posting though. I have developed a front end form which someone in the office will have to manually type the information on the timesheets into. it then saves the data in the database. the problem is is that i have only got one table and this weeks timesheet would overwrite last weeks and so on. ie at the moment i can only save one time sheet for each employee where i need to be able to store all past timesheets aswell. i know i probably need a second table but im not sure how to save several timesheets for each employee as each timesheet is made up of 12 fields.
  7. Hi Im pretty new to php and i am attempting to create a php/mysql application to store employees weekly hours worked ie. a timesheet. I have developed basic address books using php/mysql so i am familiar with storing and retrieving data. My main problem is trying to figure out how to store a new piece of information on an employee every week whithout over writing last weeks record. ie every week a new timesheet but also being able to record previous weeks timesheets. Any application i have previously created has been one entry for each record eg name address etc. things that dont change every week. Any suggestions at all would be greatly appreciated Sorry if i have over complicated what is probably a pretty basic problem.
×
×
  • 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.