rendered paste body<?phpinclude('page_parts/header.php');$submit = $_POST["submit"];$keywords = $_POST["keywords"];if(isset($submit) || isset($keywords)){doSearch($keywords);}else{getKeywords();} function getKeywords(){?><form name="frmKW" action="search.php" method="post"><h1 class="search_header">Search</h1>Keywords:<input type="text" name="keywords" maxlength="100"><br><br><input type="submit" name="submit" value="Search"></form><?php} function doSearch($search_keywords){ $arrWords = explode(" ", $search_keywords); if(sizeof($arrWords) == 0 || $search_keywords == ""){ echo "You didn't enter any keywords<br>"; echo "<a href='search.php'>Go Back</a>"; } else { for($i = 0; $i < sizeof($arrWords); $i++){ $result = mysql_query("select articleIds from searchWords where word = '".(string)$arrWords[$i]."'"); if(mysql_num_rows($result) > 0){ // Get the id's of the articles $j=0; while($row1 = mysql_fetch_array($result)){ $arrIds[$j]=$row1[0]; $j++; } //$arrIds = explode(",", $row[0]); $arrWhere = implode(" OR aid = ", $arrIds); $aQuery = "select aid, title, summary from articles where aid = " . $arrWhere; $aResult = mysql_query($aQuery); $count = 0; $articles = array(); if(mysql_num_rows($aResult) > 0){ while($aRow = mysql_fetch_array($aResult)){ $articles[$count] = array ( "aid" => $aRow["aid"], "title" => $aRow["title"], "summary" => $aRow["summary"] ); $count++; } } if(isset($articles)){ //$articles = array_unique($articles); echo "<h1 class=\"search_header\">" . sizeof($articles); echo (sizeof($articles) == 1 ? " article" : " articles"); echo " found:</h1>"; foreach($articles as $a => $value){?><a class="search_title" href="articles.php?aid=<?php echo $articles[$a]["aid"]; ?>"><b><u><?php echo $articles[$a]["title"]; ?></u></b></a><br><span class="summary_text"><?php echo $articles[$a]["summary"] . "..."; ?></span><br><a class="search_link" href="articles.php?aid=<?php echo $articles[$a]["aid"]; ?>">http://www.infraterra.net/articles.php?aid=<?php echo $articles[$a]["aid"]; ?></a><br><br><?php}}}else{echo "No results found for '$search_keywords'<br>";echo "<a href='search.php'>Go Back</a>";}}}}include("page_parts/nav.php");include("page_parts/footer.php");?>