PHP MYSQL Example

PHP MYSQL Example

PHP / mySQL is used by programmers to store and output data. Well, there is a lot more to it. PHP can use a lot of built in Internet information like rss feeds, display dates and times from a server, and print html / css...just to name a few things.The 4 commands below can be implemented to select, add, update and delete data.

Select Data

$command = "SELECT * FROM table_sort where id >0";
$result = mysqli_query($db, $command);
if($result){
echo "There are entries";
}

Insert Data

$command = "INSERT INTO table_sort VALUES(NULL,'$value','$value2','$value3',now()) where id =5";
$result = mysqli_query($db, $command);
if($result){
echo "Inserted";
}

Update Data

$command = "UPDATE INTO table_sort set name='John' where id = 2 ";
$result = mysqli_query($db, $command);
if($result){
echo "Updated";
}

Delete Data

$command = "DELETE FROM table_sort where id = 2 ";
$result = mysqli_query($db, $command);
if($result){
echo "Entry Deleted";
}