Update
Posted: Wed Apr 23, 2008 4:35 am
Hi!
I'm trying to figure out how to update a kitchenlist when you insert a new value for datorpost and if name allready exists.
If the name doesn't exists it should insert a new person in the database.
This is the code I have currently..
I'm trying to figure out how to update a kitchenlist when you insert a new value for datorpost and if name allready exists.
If the name doesn't exists it should insert a new person in the database.
This is the code I have currently..
Code: Select all
<?php
function setuser($name, $datorpost) {
$conn_id = pg_connect ("host=localhost user=cordts dbname=cordts")
or die("No contact with kitchenlist");
$query = "SELECT name FROM user where name = '$name'";
$row = pg_fetch_row($query);
if ($row[0] == $name) {$query = "UPDATE user SET datorpost = $datorpost" WHERE name = $name;}
else {$query = "INSERT INTO user VALUES ('$name', '$datorpost')";
}
pg_query ($conn_id, $query)
or die ("Cant get persons");
pg_close($conn_id);
}
?>