Hi The code is: $getbid="SELECT id FROM listing WHERE keywords LIKE `%$keyword%` ORDER BY maxb DESC LIMIT 5"; PHP: and the error is: Unknown column '%%' in 'where clause': SELECT id FROM listing WHERE keywords LIKE `%%` ORDER BY maxb DESC LIMIT 5 also if you have any comments about this code please let me know: <?php //collect bid data $content=$lrow['keywords']; $lines = explode(PHP_EOL, $content); ?> <table border=1 > <tr> <td> Keyword </td> <td> CPC </td> <td> Rank </td> <td> Method </td> <td> Bid </td> <?php // keyword list goes here ?> <td> 1st </td> <td> 2nd </td> <td> 3rd </td> <td> 4th </td> <td> 5th </td> </tr> <?php foreach ($lines as $nrow => $keyword){ $getbid="SELECT id FROM listing WHERE keywords LIKE `%$keyword%` ORDER BY maxb DESC LIMIT 5"; $fivebids=mysql_query($getbid) or die(mysql_error().': '.$getbid); //table data inputs goes here ?> <tr> <td> <?php echo $keyword ?> </td> <td> <?php $get1=getcost($keyword, $id); echo $get1; ?> </td> <td> <?php $get2=getrank ($keyword, $id); echo $get2; ?> </td> <td> Auto Bid</td> <td> <?php echo $maxb; ?> </td> <?php while($frow=mysql_fetch_array($fivebids)){ ?> <td> <?php echo getcost($keyword, $frow['id']) ; ?> </td> <?php } ?> </tr> <?php } ?> </table> <?php } PHP:
you may suggest that $keyword doesn't exist. but I tested and can confirm that $keyword exists. This is the code i used for testing <?php include 'global.php'; $id=14; $_SESSION['id']=$id; $getlisting="SELECT * FROM listing WHERE id=$id"; $resultb=mysql_query($getlisting) or die (mysql_error()); //listing rows: $lrow=mysql_fetch_array($resultb); $maxb=$lrow['maxb']; $i=1; //collect bid data $content=$lrow['keywords']; echo $content; echo "done"; $lines = explode(PHP_EOL, $content); foreach ($lines as $nrow => $keyword){ echo $keyword ?><br><?php echo $i; $i++; } ?> PHP: that outputs: computers internet softwaredone 1computers 2internet 3software 4 thanks in advance
The first thing I noticed was the back-ticks around `%$keyword%` ... should be single quotes. '%$keyword%' This seemed to indicate the problem. Unknown column '%%'