Hey, so I am really new to this stuff (php, html, sql) and I have a form, which is actually workin out pretty good 😃
But here are a few things i would like done:
I would like it to, once i pick a project number, automatically fill in the project name and client. My question is..how do you do this. My friend told me that you DONT have to use javascript...but it seems all the examples i find on google do (...javascript is confusing 🙁 )
is it possible that when a person enters their name once, it will automatically stay the same for the rest of the entries?
Also. this is a time sheet that I am making...my ideal situation would be that it was done in a somewhat spreadsheet style...so there are the headers, and then there are 14 rows for the 2 weeks in a pay period...all on the same screen. But i heard this is crappy design for a php form...is there any alternative to just doing a columnar view one entry at a time?
My code is down below 🙂
Thanks for any help! 🙂
Paul
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Toadums" />
<title>Untitled 3</title>
</head>
<body bgcolor="#CCFFFF">
<?php
#save log in information for server
$username="";
$password="";
$database="";
?>
<!-- connecting to sql server-->
<?php
mysql_connect("mysql.mattwatson.info",$username,$password) or die ("Unable to connect to server");
@mysql_select_db($database) or die("Unable to select database");
if(isset($_POST['submit'])) {
$Name=$_POST['Name'];
$Date=$_POST['Date'];
$Hours=$_POST['Hours'];
$Phase=$_POST['Phase'];
$Invoiced=$_POST['Invoiced'];
$ProjectID=$_POST['ProjectID'];
$ProjectName=$_POST['ProjectName'];
$Description=$_POST['Description'];
$Client=$_POST['Client'];
$Type=$_POST['Type'];
$query1 = "INSERT INTO tblTimesheet VALUES ('','$Name', '$Date','$Hours','$Phase','$Invoiced','$ProjectID')" ;
$query2 = "INSERT INTO tblProjects VALUES('$ProjectID','$ProjectName','$Description', '$Client', '$Type' )";
if(($results = mysql_query($query1))&&($results = mysql_query($query2))) {
echo '<font color="green">Data successfully added</font>';
} else {
die('<font color="red">Error: '.mysql_error().'</font>');
}
}
mysql_close();
?>
<form action="<?php echo($php_self); ?>" method="post">
<table border="0">
<tr><td align="right" >Name: </td><td colspan="2"><select name="Name"><option value=""></option><option value="Paul">Paul</option><option value="Ed">Ed</option></select></td></tr>
<tr><td align="right" width="20%">Date: </td><td colspan="2"><input type="text" name="Date"/></td></tr>
<tr><td align="right" >Hours: </td><td colspan="2"><input type="text" name="Hours"/></td></tr>
<tr><td align="right" >Phase: </td><td colspan="2"><input type="text" name="Phase"/></td></tr>
<tr><td align="right" >Invoiced: </td><td colspan="2"><input type="text" name="Invoiced"/></td></tr>
<tr><td align="right" >ProjectID: </td><td colspan="2"><input type="text" name="ProjectID"/></td></tr>
<tr><td align="right" >ProjectName: </td><td colspan="2"><input type="text" name="ProjectName"/></td></tr>
<tr><td align="right" >Description: </td><td colspan="2"><input type="text" name="Description"/></td></tr>
<tr><td align="right" >Client: </td><td colspan="2"><input type="text" name="Client"/></td></tr>
<tr><td align="right" >Type: </td><td colspan="2"><input type="text" name="Type"/></td></tr>
<tr><td align="right">Submit:</td><td colspan="2"><input type="submit" name="submit" value="new" /></td></tr>
</table>
</form>
</body>
</html>