Hi all,
Here is my problem.I have 4 select boxes,and the user clicks on each one.The results goes into the SELECT sql line,and the theory is that it should print out on the page.In practice however I can't get it to work.The SELECT line seems to be the problem and to date I have got three variations on this line and I have placed them in the code next to each other.Using them in turns heres what I find.
The first SELECT came up with the message:
Parse Error.syntax error,unexpected '='inC:\xampp\htdocs\harold.php on line 56.
The second line resulted in the four drop down boxes being displayed.
and the third line came up with the message
Parse Error.syntax error,unexpected '$aa=' (T_VARIABLE) inC:\xampp\htdocs\harold.php on line 56..
The second line seems to ignore the PHP altogether and just produces the drop down boxes.
Can anybody see what is wrong with the code?? Is it my SELECT or is it something else in the code.Quite new to all this.
Many thanks
Harold
<!DOCTYPE HTML>
<html>
<body>
<select name = "author">
<option value="kendavies">ken davies</option>
<option value="arthursmith">arthur smith</option>
<option value="gillrafferty">gill rafferty</option>
<option value="mollybrown">molly brown</option>
<option value="gilbert riley">gilbert riley</option>
<option value="colinwilson">colin wilson</option>
<option value="jamesgreen">james green</option>
<option value="arnoldlaing">arnold laing</option>
<option value="cathyellis">cathy ellis</option>
<option value="carolreed">carol reed</option>
</select>
<select name = "publisher">
<option value="yonkers">yonkers</option>
<option value="blueparrot">blue parrot</option>
<option value="zoot">zoot</option>
</select>
<select name = "yearpublished">
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
</select>
<select name = "genre">
<option value="adventure">adventure</option>
<option value="thriller">thriller</option>
<option value="crime">crime</option>
<option value="biography">biography</option>
<option value="romance">romance</option>
</select>
<?php
$aa = "author";
$bb = "publisher";
$cc = "yearpublished";
$dd = "genre";
mysql_connect ("localhost","root","") or die(mysql_error());
mysql_select_db ("authors") or die(mysql_error());
$strSQL = "SELECT * FROM books WHERE author = '{$aa}' AND publisher = '{$bb}' AND yearpublished = '{$cc}' AND genre ='{$dd}'";
//$strSQL = SELECT * from books WHERE author = '$aa' AND publisher = '$bb' AND yearpublished = '$cc' AND genre = '$dd' ";
// $strSQL = SELECT * FROM books WHERE author = "$aa" AND publisher = "$bb" AND yearpublished = "$cc" AND genre ="$dd";
$rs = mysql_query($strSQL);
while($row = mysql_fetch_($rs) );
{
print $row ['ID']."<br/>";
print $row ['author']."<br/>";
print $row ['booktitle']."<br/>";
print $row ['publisher']."<br/>";
print $row ['yearpublished']."<br/>";
print $row ['genre']."<br/>";
print $row ['copiessold']."<br/>";
}
mysql_close();
?>
</body>
</html>