Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
1.00/5 (1 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
<?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 5:19am
v3

1 solution

You forgot to add <li> at the front of each movie title.
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900