Hello I'm trying to learn php. I'm using phpmyadmin with xampp. I want to listen according to the following query:
"$add='SELECT * FROM movielibrary WHERE username="$libraryuser"';
But there is no element coming to the mylibrary.php page. When I try to echo $libraryuser, it is correct but when I write to the sql query, it's not matching and my table is blank. My username is "info" and if I write
"$add='SELECT * FROM movielibrary WHERE username="info"';
It is correct but I need to do $libraryuser.
What should I do?
This are the screenshots for my problem:
this is when i write to username='info' it is okey
this is when i write to $libraryuser there is no listing
I also tried
'username'=$libraryuser , "username"=$libraryuser , username='$libraryuser , username="$libraryuser
but it did not work.
<?php
require_once("config.php");
session_start();
$libraryuser=$_SESSION['user'];
echo $libraryuser;
$add='SELECT * FROM movielibrary WHERE username="$libraryuser"';
echo "<table>
<tr>
<td width=2%></td>
<td height=175 width=20%>
<a href=index.php>
<img src=images/Logo.png width=400></a>
</td>
<td width=55%></td>
<td width=12% valign=top >
<td width=12% valign=top >
<div class=row>
<div class='col-md-3 col-sm-3 col-xs-6'> <a href=logout.php class='btn btn-sm animated-button victoria-two'>Logout</a> </div></td>
</tr>
</table>";
echo "<center><font size=10><b>My Library</b></font></center> <table>";
if($result=mysqli_query($conn,$add)) {
echo "</br></br></br></br><table width=%70 border='1' align=center cellspacing='0' cellpadding='6'>
<tr align='center' bgcolor='#999966'>
<td>
<b>Movie Name</b>
</td>
<td>
<b>Director </b>
</td>
<td>
<b>Cast</b>
</td>
<td>
<b>Year</b>
</td>
<td>
<b>Runtime</b>
</td>
<td>
<b>Movie Genre</b>
</td>
</tr>";
while($read=mysqli_fetch_array($result)){
echo "
<tr align='center' bgcolor='#c2c2a3'>
<td>
$read[movie_name]
</td>
<td>
$read[director]
</td>
<td>
$read[movie_cast]
</td>
<td>
$read[year]
</td>
<td>
$read[runtime]
</td>
<td>
$read[movie_genre]
</td>";
}
}
echo "</tr>
</table>";
?>