Home N-13 News Forums Help Search
RegisterForgot password?
How to add image to post necklacesdiscou
Known bugs - 4.0.3 necklacesdiscou

Latest N-13 News 4.0.3

What is N-13 News?
Where can I get help?
Known bugs

Forums Help & Support Search Feature
1 2
Chris
Posted on 30 May 2008, 00:43:29

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

Only use this if you have a version prior to 3.3 installed. 3.3 and above have a built in search function.

A few people had requested a search feature to search the news articles. I was going to add this in the next version of the script but in the time being you can use this. Just copy the code below into a new file, its pretty basic but easily customizable

Code:
<?php

include 'db.php';
include 
'config.php';

function 
searchform(){
echo 
'
<form method="post" action="">
<input type="text" name="searchstring"> <input type="submit" name="searchsubmit" value="Search" />
</form>
'
;
}
if(
$_POST['searchsubmit']){
   
$string = slash2($_POST['searchstring']);
   
$sql = "SELECT * FROM $newstable WHERE title LIKE '%$string%' OR shortstory LIKE '%$string%' OR story LIKE '%$string%'";
   
$query = mysql_query($sql);
   
$amount = mysql_num_rows($query);
   echo 
"Results found: <b>$amount</b>";
   echo 
"<hr />";
   while(
$row = mysql_fetch_array($query)){
        echo 
"<a href=\"index.php?id=$row[id]\"/>$row[title]</a><br />";
   }
}else{
    
searchform();
}    
?>
#1800
Last edited by Chris at 2010-02-01 09:12:36 Reason:
Angel
Posted on 01 Feb 2010, 03:17:18

Access: Member
Total Posts: 9
Joined: 2010-02-01

not working in 3.4

I need to add a simple finder in a page that not this within the folder news
please by my English, thanks (single I speak Spanish)
#1779
Chris
Posted on 01 Feb 2010, 08:40:14

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

3.4 has its own built in search you don't need to use this code.

Add ?goto=search to your url like so

http://domain.com/news/index.php?goto=search

http://domain.com/?goto=search
#1780
Angel
Posted on 01 Feb 2010, 13:11:42

Access: Member
Total Posts: 9
Joined: 2010-02-01

What I need is a code simple (without options) to include in home of the Web
and that direccione to /news/search.php but already with the results of the search

pardon by my English
#1785
Chris
Posted on 01 Feb 2010, 13:44:34

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

To include the script into your design use the following code.

Code:
<?php
include 'news/index.php';
?>
#1786
Chris
Posted on 01 Feb 2010, 14:55:38

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

When you add this code to your page

Code:
<?php
include 'news/index.php';
?>


Then add ?goto=search to the URL of that page, the page will show the search form which will allow you to search through your news articles.
#1791
Angel
Posted on 01 Feb 2010, 15:13:20

Access: Member
Total Posts: 9
Joined: 2010-02-01

pardon but what I need is code form search simple to include in home, and that from that search shows the results.

pardon but what I need is code form search simple to include in home, and that from that search shows the results.
I pass an example to you:

finder in cover of the Web

.....

and results in news/search.php


....
#1801
Last edited by Angel at 2010-02-08 13:20:38 Reason:
Chris
Posted on 01 Feb 2010, 20:00:16

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

Currently the only way to do this is to include the news script where you want the search form to show, then add ?goto=search to the URL of the page, this will then show the search form where the news script is included.

I'll change this in the next version so that you can specify a variable before the include to have the search form show straight away.
#1802
Angel
Posted on 01 Feb 2010, 20:16:28

Access: Member
Total Posts: 9
Joined: 2010-02-01

Ok, the finder tendria that like the one of the forum, simple and if one is wanted elije options, as this one must choose date, archives and this tendrian that to be options not obligatrorias, will look for the return to make a simple finder to add outside the folder news.
pardon by my English, thanks.
#1803
Wackyracer8
Posted on 23 Feb 2010, 15:59:21

Access: Member
Total Posts: 8
Joined: 2010-02-22

So can I just include the form actually into the index page? So when the user visits the index page, at the top right hand corner there is a search box where the user can search rather than looking though all the posts.

Can this be done?

Many thanks.
#1948
1 2
Network-13.com © 2013