I could not figure out if I am doing this right. I am trying to output results from my search, however I am unsure if this is done properly. Plus I'm getting this error.
Parse error: syntax error, unexpected '''' (T_CONSTANT_ENCAPSED_STRING) in /usr/local/www/project/OlegarioJW/largecoursework/tobakuhome.php on line 152
In addition, I am intending to put it inside a div as well as two of my results into <a>
tag as these will have links and they are all inside a variable. Is this how it is done?
Below is my code:
<html>
<header></header>
<body>
<?php
$serverName = "example.com";
$dbName = "abc";
$user = "abc";
$pass = "abc";
$connection = mysqli_connect($serverName, $user, $pass, $dbName);
if (!$connection){
die("Connection failure" . mysqli_connect_error());
}
?>
<form id ="search" action="tobakuhome.php" method="post">
<input type="text" name="search" placeholder="Search Game titles here"/>
<input type="submit" value="Go" />
</form>
<?php print("$output"); ?>
<?php
$output = '';
if (isset($_POST['search'])){
$searching = $_POST['search'];
$searching = preg_replace("#[^0-9a-z]#i","", $searching);
}
$query = "SELECT * FROM Software WHERE name LIKE '%searching%' OR description LIKE '%$searching%' OR exclusivity LIKE '%$searching%' OR format LIKE '%$searching%'";
$result = mysqli_query($connection, $query) or die("no results found");
$count = mysqli_num_rows($query);
if($count ==0){
$output = 'Sorry, No results was found.';
}else{
while($row = mysqli_fetch_array($query)){
$Tname = $row['Name'];
$Tdes = $row['description'];
$Timg = $row['image'];
$Texcl = $row['exclusivity'];
$Tform = $row['format'];
$Tprice = $row['price'];
$id = $row['id'];
$output .= '<div id="data">''<ul id="itemgal">'
'<li id = "softitem">'
'<a id= "row" href = "displaysoftware.php?id=" .$id." '.$Tname.' />' '</a>'
'<a id= "row" href = "displaysoftware.php?id=" .$id." '.$Timg.' />' '</a>'
'<br />'
'<h3>'.$Tform . '</h3>''</td>'
'<br />'
'<h4>'.$Texcl . '</h4>''</td>'
'<h5>' '£' . $Tprice.'</h5>'
'</li>'
'</ul>'
'</div>';
}
}
?>
</body>
</html>