The old mysql_* extension was depreceated as of version 5.5 of PHP, you should be migrating over to either the mysqli_* extension or PDO.
Once you’ve migrated over to either the mysqli_* extension or PDO you should be using prepared statements when sending queries to the database that include user submitted data.
When dealing with user submitted data you should be sanitizing it to make sure that it’s what you expect. I’m assuming that the id field is a numeric type, when processing the $_POST[‘id’] you could use the is_integer() function to check if the user has submitted a number.
Whether you migrate over to either the mysqli_* extension or PDO you should use exceptions (try-catch blocks) to handle any errors that get thrown back at you by the MySQL server.
Yes, you are asking how to display an item as sold but you really haven’t shown your display query and the code for that section. In the examples given in this thread, the $variable would represent $row[‘sold’] in your result set. So make sure you have sold as a selected field and try implementing one of these examples. Reply with your query and display section if you have problems.
EDIT: I also wanted to note that isset() might not be your best or complete solution as $row[‘sold’] WILL BE set if you are calling that field. I would also compare to your expected value, which was 1. Using Mittineague’s example from above, you have something like this.
@Drummin Would an if statement work just as well here?
Changing your example a bit:
<?php
// Will be empty until set
$sold_status;
// Check if row exists and if value is 1
if(isset($row["sold"]) && $row["sold"] == 1){
$sold_status = "Sold!";
} else {
$sold_status = "Not sold";
}
echo $row["item"] . " is " . $sold_status;
?>