this ought to be simple but am yet to find an answer for it (i have searched the questions in stackoverflow). am on php and i have a table books on mysql. What i want is a list displayed in my webpage with these specifics on a table created by php. I know the mysql code:
SELECT title FROM books WHERE category='currently reading'
applying that on php has brought this error, Parse error: syntax error, unexpected 'currently' (T_STRING)
Here is my php code:
<?php
include('include/databaseconnection.php');
include('include/insertingbooks.php');
// selecting data
$result = mysql_query ('SELECT title FROM books WHERE category='currently reading'';);
//("SELECT title FROM books WHERE category LIKE $currently");
//opening table tag
echo "<table border = 1px>";
while ($data = mysql_fetch_array($result)) {
// printing table row
echo'<tr>';
echo '<td>'.$data['title'].'</td>';
echo'</tr>'; // closing table row
}
echo '</table>';
?>
If i decide to leave out WHERE clause, it works perfectly except it displays all the books. The options i have tried already
- using
WHERE category LIKE $category
while setting up a variable$category = "currently reading";
but it dint work. - trying to link it to the form i got the the values of category from by adding
include('include/insertingbooks.php');
(which contains$category =$_POST ['category'];
) and trying to put $category. - using WHERE not but it didnt work at all.