|
Posted by plato on 10/13/84 11:27
"Marc" <mbradshaw@beasolutions.com> wrote in message
news:1127462683.52821.1@doris.uk.clara.net...
> plato wrote:
> > Reasons the database won't update might be? (Places is set as an
integer)
>
> When posting regarding a problem you're having, it's always helpful if
> you can post the error as well...
>
> Marc
The script:
<?PHP
//alter you variables here
//alter you variables here
$host = "localhost";
$username="";
$password="";
$database="paul";
$submit = $_POST['submit'];
$course = $_POST['course'];
//
$link = mysql_connect($host, $username, $password)
or die("Cannot connect to database");
mysql_select_db($database)
or die("Cannot select database");
print("Debug: $course<br>");
//check if we can update the database
if($submit)
{
$result = mysql_query("update test set places=places-1 where
number='$course'")
or die("Update cannot be executed");
print("Changed database<br>");
}
//now we make the query which will ask the database for the course
//information
//change the my_table to your course table name
$query = "SELECT * FROM test ";
$result = mysql_query($query)
or die("Query cannot be executed");
print("<FORM method=post>\n");
print("<SELECT name=course>\n");
//now we are going to print the information to your screen
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
printf("<OPTION value='%s'> %s (%s places available)</OPTION>\n",
$row['course'],$row['course'],$row['places']);
}
print("</SELECTED>\n");
print("<INPUT name='submit' type='submit'>\n");
print("</FORM>\n");
?>
The result:
Debug: Course 1
Update cannot be executed
Not sure what is wrong... don't know why the db won't update. Any ideas I
can try/check?
thanks
plato
Navigation:
[Reply to this message]
|