Well i am quite new with PHP
and for school we have to make a PHP script which reffers to a Database,
Well, more explicit, we have this form showing all "employees"
last name etc.
made it week before,
and we had to add a new bar to also upload pictures and show them.
So i made this script but it won't work.
And maybe it's just me being stupid..
But please help me
EDIT: it's obvious that pictures reffers to the picture iwant to upload and show.
2nd EDIT: Found out i missed a " , "
Well now the problem is that when i run it and try to upload a picture i won't see anything
<?php
function displayAllEmployees() {
$sql = "SELECT * FROM `Employees` ORDER BY `LastName`";
$result = mysql_query($sql);
echo"<h1>Werknemers</h1>";
echo"<br/>";
echo"<input type="button" onclick="document.location.href='?action=addemployee';" value="Werknemer toevoegen" />";
echo"<br/>";
echo"<br/>";
echo"<table>";
echo" <tr>";
echo" <th>Employee ID</td>";
echo" <th>Last Name</td>";
echo" <th>Phone Number</td>";
echo" <th>Foto</td>";
echo" <th>Actie</td>";
echo" </tr>";
while($row = mysql_fetch_assoc($result)) {
$row = escapeArray($row);
echo" <tr>";
echo" <td>".$row['EmployeeID']."</td>";
echo" <td>".$row['LastName']."</td>";
echo" <td>".$row['PhoneNumber']."</td>";
echo" <td>".$row['Picture']."</td>";
echo" <td>";
echo" <a href="index.php?action=editemployee&id=".$row['EmployeeID']."">Bewerken</a>";
echo" |";
echo" <a href="javascript:confirmAction('Zeker weten?', 'index.php?action=deleteemployee&id=".$row['EmployeeID']."');">Verwijderen</a>";
echo" </td>";
echo" </tr>";
}
echo"</table>";
}
function displayAddEmployee() {
echo"<h1>Werknemer bewerken</h1>";
echo" <form method="post" action="index.php?action=insertemployee">";
echo" <table>";
echo" <tr>";
echo" <td>werknemernummer:</td>";
echo" <td><input type="text" name="EmployeeID" /></td>";
echo" </tr>";
echo" <tr>";
echo" <td>achternaam:</td>";
echo" <td><input type="text" name="LastName" /></td>";
echo" </tr>";
echo" <tr>";
echo" <td>telefoonnummer:</td>";
echo" <td><input type="text" name="PhoneNumber" /></td>";
echo" </tr>";
echo" <tr>";
echo" <td>Foto:</td>";
echo" <td><input type="file" name="Picture" /></td>";
echo" </tr>";
echo" <td></td>";
echo" <td><input type="submit" value="Opslaan" /></td>";
echo" </tr>";
echo" </table>";
echo" </form>";
}
function displayEditEmployees() {
$sql = sprintf( "SELECT * FROM `Employees` WHERE `EmployeeID` = %d",
mysql_escape_string($_GET['id']) );
$result = mysql_query($sql);
if($row = mysql_fetch_assoc($result)) {
$row = escapeArray($row);
echo"<h1>Werknemer bewerken</h1>";
echo" <form method="post" action="index.php?action=updateemployee">";
echo" <table>";
echo" <tr>";
echo" <td>Titel:</td>";
echo" <td><input type="text" name="EmployeeID" value="".$row['EmployeeID']."" /></td>";
echo" </tr>";
echo" <tr>";
echo" <td>Achternaam:</td>";
echo" <td><input type="text" name="LastName" value="".$row['LastName']."" /></td>";
echo" </tr>";
echo" <tr>";
echo" <td>Telefoon Nummer:</td>";
echo" <td><input type="text" name="PhoneNumber" value="".$row['PhoneNumber']."" /></td>";
echo" </tr>";
echo" <tr>";
echo" <td>Foto:</td>";
echo" <td><input type="text" name="Picture" value="".$row['Picture']."" /></td>";
echo" </tr>";
echo" <tr>";
echo" <td></td>";
echo" <td><input type="submit" value="Opslaan" /></td>";
echo" </tr>";
echo" </table>";
echo" <input type="hidden" name="EmployeeID" value="".$row['EmployeeID']."" />";
echo" </form>";
}
else {
die("Geen gegevens gevonden");
}
}
function addEmployee() {
$sql = sprintf("INSERT INTO `Employees` (`EmployeeID`, `LastName`, `PhoneNumber`) VALUES ('%s', '%f', '%f', '%f')",
mysql_escape_string($_POST['EmployeeID']),
mysql_escape_string($_POST['LastName']),
mysql_escape_string($_POST['PhoneNumber']),
mysql_escape_string($_POST['Picture']) );
mysql_query($sql);
header("location: index.php?action=employees");
exit();
}
function updateEmployees() {
$sql = sprintf("UPDATE `Employees` SET
`EmployeeID` = '%s',
`LastName` = '%s',
`PhoneNumber` = '%s'
`Picture` = '%s'
WHERE `EmployeeID` = %d",
mysql_escape_string($_POST['LastName']),
mysql_escape_string($_POST['PhoneNumber']),
mysql_escape_string($_POST['EmployeeID'])
mysql_escape_string($_POST['Picture']) );
mysql_query($sql);
header("location: index.php?action=employees");
exit();
}
function deleteEmployees() {
$sql = sprintf("DELETE FROM `Employees` WHERE `EmployeeID` = %d", mysql_escape_string($_GET['id']));
mysql_query($sql);
header("location: index.php?action=employees");
exit();
}
?>
Simultaneous select/update/insert
HiHow would I need to go about when 2 users update a single row simultaneous? And how would I need to go about when 2 users want to edit a row?Should I first lock the table, update the row to indicate
foreach loop, assistance request
I would like some guidance on the usage of foreach as I try to parse through a large database and whittle down to a few select stocks. I'm currently doing this with vb, but I'm wanting to get it
Need Reporting Advice
My SQL server doesn't support MS SQL reporting services that comes with SQL Enterprise or Express. Then the administrator suggested that I google for alternatives. I'm a newbie and don't even know
Login Script Issues
I am using a script I got from http://phpsense.com/php/php-login-script.html in order to allow people to login but prevent multiple logins with the same username. Everything appears to work fine
Trigger tag in aspx is not coming
hi all ,iam new to ajax, iam using file upload inside the update pannel but right now i want to use trigger tag but it is not coming, for that whether i want to install anything like toolkit ,please
disabling a button server-side then re-enabling client-side breaks button postback
I have a tabbed container and a button (not in the container) on a page. If the first tab is selected, I want the button enabled. If the second is selected, I want the button disabled. I have created
Displaying Site Logo/Icon on a Title tag
really need some help out here. I want to insert a Logo/Icon just like the one close to the "PHP Freaks" title bar. But kinda finding it difficult to do that. Don't know if to echo the image
pass form variables straight to email, no database required?
hello all,im working on this form...http://www.adobedayevents.com/project_request/project_request.phpWhat we want to use this form for, is for our client Adobe, to have there field marketing managers
split values
I have values that are returned to me in this format:name=>test,age=>49What I want to get out of this is an array like thisarray('name'=>'test','age'=>'49');I was hoping
error help - Dynamic Image
I've been working on making my site less cluttered in the directories and more secure lately. In an attempt to prevent bandwidth theft from other people using images, I decided to switch all my site