Jump to content

sonofharrold

New Members
  • Posts

    6
  • Joined

  • Last visited

sonofharrold's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hmmm !!So should I be using the POST attribute in the HTML Form to send the value from my Listbox back to the a variable that will be placed into the SELECT string Kind Regards H
  2. Hi tryingtolearn, Thanks for your reply.You may well be right.I am quite new to this and trying to make some logical jumps based on my sparse grasp of the language.Learning all the time though Kind regards H.
  3. Hello ginerjm Thanks for your reply.No as it is the code isn't working.Are you suggesting that the code needs rearrangeing in some way.Interestingly,when I use the second sql line I just get the drop boxes,it's as if only the html is being read and the php ignored.I am beginning to think that the while loop might be at fault. Kind Regards Harold
  4. Hi all, many thanks for your replies I tried all three SELECTS above,but to no avail. 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. I am wondering if the php can't read the HTML code. Here is the complete code and I left the three mysql SELECTS in to have a look at. <!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_array($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> >
  5. Hi both, Thanks for the replies.Here is the error. Parse error: syntax error, unexpected '`' in C:\xampp\htdocs\boxes.php on line 59 It refrers to the `` around the reference to the books table.So I tried many a variation on that including ' and "" but then I got the same error up just referring to those.I also left the quotes around books out altogether,the I get this Parse error: syntax error, unexpected 'books' (T_STRING) in C:\xampp\htdocs\boxes.php on line 59 So its a bit of a catch 22. I am just trying different variations on the SELECT line to see if I can crack it but so far to no avail. Again many thanks for your replies. Harold
  6. Hi all, The code creates 4 select boxes.The user clicks on one item in each of the boxes and these are entered into the SQL statement.Trouble is I keep getting error after error all referring to line 59(the SQL statement line) can any keen eyed PHP freak see what I am doing wrong(or even if the whole of the code is any good)..Not too experienced with php so any comments suggestions(or laughs) greatly appreciated. <!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> $aa = "author" $bb = "publisher" $cc = "yearpublished" $dd = "genre" <?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."'" "; $rs = mysql_query($strSQL;); while($row = mysql_fetch_array($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>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.