Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="index.php" method="GET">
- <input type="hidden" name="url" value="search" />
- <input type="text" name="query" class="text" placeholder="Søk etter prosjekter.." style="height:12px;"/>
- <input type="submit" value="" class="search-button" />
- </form>
- <?php
- $varr = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($url));
- $varr = html_entity_decode($url,null,'UTF-8');
- $query = $_GET['query'];
- echo utf8_decode(urldecode( $query));
- $min_length = 2;
- if(strlen($query) >= $min_length){
- $query = htmlspecialchars($query);
- $query = mysql_real_escape_string($query);
- $raw_results = mysql_query("SELECT *, account_created FROM users
- WHERE (`username` LIKE '%".$query."%') OR (`motto` LIKE '%".$query."%')ORDER BY account_created DESC") or die(mysql_error());
- $num_rows = mysql_num_rows($raw_results);
- if(mysql_num_rows($raw_results) > 0){
- while($results = mysql_fetch_array($raw_results)){
- $timestamp=$results['account_created'];
- echo '
- <a href="http://prosjektdatabasen.com/prosjekt/'.$results['username'].'"><div class="searchbg">
- <text style="float:right; font-size:12px; color:#2e7297;">' . gmdate("d.m.y", $timestamp) . '
- </text>
- <text style="font-size:17px; color:#494747; font-weight:bold; line-height:140%;">'.$results['username'].'</text><br />
- <text style="color:#5e5d5d; line-height:130%;">' . wordwrap(substr($results['motto'], 0,120), 58 ,"\n", TRUE) . '...</text></div></a>
- ';
- }
- }
- else{ // if there is no matching rows do following
- echo '<text style="font-size:13px;">Fant ingen prosjekter med søket: <strong>'. $_GET['query'] .'</strong></text>';
- }
- }
- else{ // if query length is less than minimum
- echo '<br /><text style="font-size:13px; color:red;">Søket må inneholde minst ' . $min_length . ' bokstaver.</text>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement