Well in PHP I am working with MYSQL databases, and able to insert data into the mysql database through a PHP form.I need to list the entries that are already in the database alphabetically. Now after adding data that data needs to appear red in the table of information. Here is the code I have so far, but IDK how to make the entry in the table red.
<html>
<head>
<style type="text/css">
.container {
width: 500px;
clear: both;
}
.container input {
width: 100%;
clear: both;
}
</style>
</head>
<body>
<?php
//Vars
$movieName = $_POST['movieName'];
$movieCategory = $_POST['movieCategory'];
$price = $_POST['price'];
$stock = $_POST['stock'];
$dbc = mysqli_connect('localhost', 'root', 'root', 'movies') or DIE('SHIP BE BROKE!');
$result = mysqli_query($dbc, "SELECT * FROM `movies` ORDER BY `movieName` ASC");
$queryInsert = "INSERT INTO `movies`.`movies` (`ID`, `movieName`, `movieCategory`, `price`, `stock`) VALUES (NULL, '$movieName', '$movieCategory', '$price', '$stock');";
echo '<table border="1" width="100%"><tr bgcolor="#d1d1d1"><td>Movie Name</td> <td>Category</td><td>Price</td><td>Stock</b></td></tr>';
while($row = mysqli_fetch_array($result)){
echo '<tr>';
echo '<td>'.$row['movieName'].'</td>';
echo '<td>'.$row['movieCategory'].'</td>';
echo '<td>'.$row['price'].'</td>';
echo '<td>'.$row['stock'].'</td>';
echo '</tr>';
}
echo '</tr></table></table>';
echo '<h3>Insert a Movie into the database</h3>';
if($movieName == null){?>
<div class="container">
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Movie Name: <input type="text" name="movieName">
Movie Category: <input type="text" name="movieCategory">
Price: <input type="text" name="price">
Stock: <input type="text" name="stock">
<input type="submit" name="submit" value="Submit">
</form>
</div>
<?php
}
if($price != null){
mysqli_query($dbc, $queryInsert) or DIE ('YOUR QUERY SUCKS!');
echo '<font color="red">';
echo $movieName.', '. $movieCategory.', '.$price.', '.$stock;
echo '</font>';
}
mysqli_close($dbc);
?>
</body>
</html>