Thanks to all the contributors. I've read here for some time before I decided to learn php, and now here I am.
In learning to code dynamic web pages, I am building a basic movie review site. I've been trying to understand the logic behind sorting arrays but I'm hitting a wall:
<?php
session_start();
//Check to see if user has logged in with a valid password
if ($_SESSION['authuser']!=1) {
echo "Access Denied. ";
exit();
}
?>
<HTML>
<HEAD>
<TITLE>My Movie Site- <?php echo $_REQUEST['favmovie'] ?></TITLE>
</HEAD>
<BODY>
<?php include "header.php" ?>
<?php
$favmovies = array("Life of Brian", "Stripes", "Office Space", "The Holy Grail",
"Matrix", "Terminator 2", "Star Wars", "Close Encounters of the Third Kind", "S
ixteen Candles", "Caddyshack");
if (ISSET($_REQUEST['favmovie'])) {
echo "Welcome to our site!";
echo $_SESSION['username'];
echo "! <br>";
echo "My favorite movie is ";
echo $_REQUEST['favmovie'];
echo "<br>";
$movierate-5;
echo "My rating for this movie is: ";
echo $movierate;
}
else {
echo "My top 10 movies are:<br>";
if (ISSET($REQUEST['sorted'])) {
sort($favmovies);
}
foreach ($favmovies as $currentvalue) {
echo $currentvalue;
echo "<br>\n";
}
}
?>
I'm able to list the top 10 movies, but unable to get them sorted correctly. Please tell me what I'm missing!?
😕