Im trying to display information from my database that's been fetched by a MySql query. I set this error
Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\1\search.php on line 14
Here is the code for search.php
<?php
if (isset($_POST['searchterm'])){
mysql_connect("localhost","root","Oliver");
mysql_select_db("videos");
$search = mysql_real_escape_string(trim($_POST['searchterm']));
$find_videos = mysql_query("SELECT * FROM `videos` WHERE `keywords` LIKE'%$search%'");
while($row = mysql_fetch_assoc($find_videos))
{
$name = $row['name'];
echo "<table">";
echo "<tr>";
echo "<td>$name</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$name</td>";
echo "</tr>";
echo "</table>";
}
}
?>
<?php
include('session.php');
?>
<!DOCTYPE html>
<html>
<head>
<link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
<link rel="icon" type="image/ico" href="images/favicon.ico">
<script src="http://vjs.zencdn.net/4.12/video.js"></script>
<link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.12/video.js"></script>
<style type="text/css">
.vjs-default-skin .vjs-control-bar { font-size: 125% }
</style>
<meta charset="utf-8">
<title>Network TV | search</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.css" />
<link href="css/font-awesome.css" rel="stylesheet" />
<link href="css/3.1.1/animate.css" rel="stylesheet" />
<link rel="stylesheet" href="css/styles.css" />
</head>
<body style="overflow-x: hidden">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Network TV</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class=""><a href="\1\index.php">Home</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script>
</html>
I already have the form setup to POST the information to this page. When the information is display it's just in a list hanging off the top left side of the screen, i'm trying to display it in a table in the center of the. Here is some examples of things I tried.
echo "<table style=text-align:center">"";
echo "<tr>";
echo "<td>$name</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$name</td>";
echo "</tr>";
echo "</table>";
This gives me error Parse error: syntax error, unexpected '"<table style="' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in C:\xampp\htdocs\1\search.php on line 13
Then I tried.
echo "<table style=""width:100%">";
echo "<tr>";
echo "<td>Jill</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Eve</td>";
echo "</tr>";
echo "</table>";
and I got error
Parse error: syntax error, unexpected '"width:100%"' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in C:\xampp\htdocs\1\search.php on line 14
I have no idea whats wrong. any help is really appreciated
Marked as duplicate I have no idea what i'm fixing so unfortunately its no help to me. im sure it will help someone else later down the line.
Image and update
Here is an image how it looks now.
as you can see the 'Name of movies' is being repeated each time.
Code update
echo '<table style="width:100%">';
echo "<tr>";
echo "<td>Name of movie</td>";
echo "</tr>";
echo "<tr>";
echo "<td>$name</td>";
echo "</tr>";
echo "</table>";
Update 2
<?php
if (isset($_POST['searchterm'])){
mysql_connect("localhost","root","Oliver");
mysql_select_db("videos");
$search = mysql_real_escape_string(trim($_POST['searchterm']));
$find_videos = mysql_query("SELECT * FROM `videos` WHERE `keywords` LIKE'%$search%'");
while ($row = mysql_fetch_array($find_videos, MYSQL_BOTH)) {
{
$name = $row['name'];
}
}
}
?>
<?php
include('session.php');
?>
<!DOCTYPE html>
<html>
<head>
<link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
<link rel="icon" type="image/ico" href="images/favicon.ico">
<script src="http://vjs.zencdn.net/4.12/video.js"></script>
<link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.12/video.js"></script>
<style type="text/css">
.vjs-default-skin .vjs-control-bar { font-size: 125% }
</style>
<meta charset="utf-8">
<title>Network TV | search</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.css" />
<link href="css/font-awesome.css" rel="stylesheet" />
<link href="css/3.1.1/animate.css" rel="stylesheet" />
<link rel="stylesheet" href="css/styles.css" />
</head>
<body style="overflow-x: hidden">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Network TV</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class=""><a href="\1\index.php">Home</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="v-center">
<h1 class="text-center" style="color:white">Welcome to Network TV</h1>
<table class="table" style="width:10%">
<thead>
<tr>
<th>Movie name</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $name; ?></td>
</tr>
</tbody>
</table>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script>
</html>