No problems but i need help changing my old search.php code to PDO or mysqli and i would like to have a working dropdown list (populated with the data from the publisher table) and search box. Im having trouble changing the code as im not familiar with PDO or mysqli.
My old code form search.php / (The dropdown list dosent work here. I couldent get it to work hence me creating this topic.)
[code]
<select name="$dropdown" style="font-family: 'ariel'; font-size: 17px; width: 190px; height: 27px; position:absolute; left: 383px; top: 256px">
<option>-----------</option>
<?php query() ?>
</select>
<?php close() ?>
<input type="text" name="k" size="50" onfocus="if (this.name=='k') this.name=''; value="<?php echo $_GET["k"]; ?>" style="width: 203px; position:absolute; left: 586px; top: 256px; height: 27px; right: 567px; border:thin red solid" />
<input id="button" type="submit" value="Search" style="position:absolute; left: 800px; top: 256px; height: 27px;" />
<input type="reset" id="button" style="position:absolute; left: 873px; top: 256px; height: 27px; width: 57px; value="Reset"/>
[/code]
The search code.
[php] <?php
$k = $_GET[‘k’];
$terms = explode(" ", $k);
$query = "SELECT * FROM search WHERE ";
foreach ($terms as $each){
$i++;
if ($i == 1)
$query .= "keywords LIKE '%$each%' ";
else
$query .= "OR keywords LIKE '%$each%' ";
}
// connect
mysql_connect(DB_HOST,DB_USER,DB_PASS);
mysql_select_db("search");
$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if ($numrows > 0){
while ($row = mysql_fetch_assoc($query)){
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
$keywords = $row['keywords'];
$link = $row['link'];
echo "<br /><h3><a href='$link'>$title</a></h3>
$description";
}
}
else
echo "No results found for \"<b>$k</b>\"";
//disconnect
mysql_close();
?>[/php]
If all of this works i would be happy to donate 