Click here to Skip to main content
13,865,647 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
<o1> function is not working in my code , it doesnot echo in list form in with 123 marks rather it just print in straight line like below

Welcome to my movie review site!
Today is January 20, 2019
My top 5 favourite movies (sorted alphabetically) are:

CaddyshackClose encounters of the third kindLife of BrianMatrixOffice space
it should have printed like this
1.Caddyshack
2.Close encounters of the third

What I have tried:

<?php
session_start();
if ($_SESSION['authuser'] !=1) {
   echo "Sorry , but you don\t have permission!";
   exit();
}
?>

 
  <title>
<?php
if (isset($_GET['favmovie'])) {
    echo ' - ';
    echo $_GET['favmovie'];
}
?>	
  
 
 
<?php include 'header.php'; ?>
<?php
$favmovies = array('Life of Brian',
                   'Stripes',
				   'Office space',
				   'The holy Grail',
				   'Matrix',
				   'Terminator 2',
				   'Star trek',
				   'Close encounters of the third kind',
				   'Sixteen Candles',
				   'Caddyshack');
				  
if (isset($_GET['favmovies'])) {
    echo 'Welcome to our site, ';
    echo $_SESSION['username'];
    echo '! <br>';
    echo 'My favourite movie is ';
    echo $_GET['favmovies'];
    echo '<br>';
    $movierate = 5;
    echo 'My movie rating for this movie is: ';
    echo $movierate;
} else {
    echo 'My top ' . $_POST['num'] . ' favourite movies';
   
    if (isset($_POST['sorted'])){
        sort($favmovies);
        echo ' (sorted alphabetically) ';
   }
   echo 'are:<br>';
   
   $numlist = 0;
   echo '<ol>';
   while ($numlist < $_POST['num']) {
       echo $favmovies[$numlist];
       echo '</1i>';
       $numlist = $numlist + 1;
   }
   echo '</ol>';
   
}
?>
Posted
Updated 20-Jan-19 6:19am
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You forgot to add <li> at the front of each movie title.
   
Comments
Member 13795308 21-Jan-19 4:46am
   
its still not working , in my php book the code is like above but when I run it it prints in same line without marks.While according to the book itshould print in different lines with marks
Richard MacCutchan 21-Jan-19 4:53am
   
If that is truly what the book says, then throw it away, it is wrong. Each item in the list must be surrounded by the <li> and </li> tags (as with all HTML data). Your code only includes the terminating tag, not the opening one. Change your code to the following:

echo '<ol>';
while ($numlist < $_POST['num']) {
echo '<1i>';
echo $favmovies[$numlist];
echo '</1i>';
$numlist = $numlist + 1;
}
echo '</ol>';

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190214.1 | Last Updated 20 Jan 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100