Thanks, but I couldnt get it right. So heres my code, and you`re invited to take a look!!! There are two files: the first is just listing a bunch of shops. If you click on one of them, you're taken to a page with more detailed info on the shop. (a shop ID is refered on to this page). On this page there is a text field that takes user input and puts it in the database ....
The problem: It works well when I'm using a submit button, but I can't seem to get it to work using a pic. PLEASE HELP!
Heres the code:
ALLSHOPS.PHP
<body>
<?php
$hostname = "localhost";
$username = "root";
//$password = "yourpassword";
MYSQL_CONNECT($hostname,$username/,$password /) OR DIE("Unable to connect to database");
@mysql_select_db("database") or die("Unable to select database");
$resultat = @("select * from shop order by shopID");
echo("All the shops:" . "<br>");
while($rad1 = @mysql_fetch_array($resultat)) {
$navn = $rad1["shopname"];
$type = $rad1["shopID"];
echo("<a href='showshop.php?type=" . $type . "'>" . $navn . "</a><br>");
}
?>
</body>
SHOWSHOP.PHP
<body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("database", $db);
if($submit) {
$skl = "UPDATE shop SET staff = '$staff_amount' WHERE shopID = $id";
$result = mysql_query($skl) or die ("Not updated");
print mysql_error();
echo "Update registered\n";
?>
<a href = "allshops.php"> Back to the shops</a>
<?php
}
else {
$sql = "SELECT * FROM shop WHERE shopID = $type";
$result = mysql_query($sql);
while ( $row = mysql_fetch_array($result) ) {
echo("<p>" . $row["shopname"] ." --- " . $row["staff"] . "</p>");
}
?>
<form method = "Post" ACTION = "<?php echo $PHP_SELF ?>">
<input TYPE = "hidden" name = "id" VALUE = "<?php echo $type ?>">
Staff amount: <input type = "Text" name = "staff_amount">
<input type = "submit" name = "submit" value = "Set amount">
</form>
<?php
}
?>
</body>