Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
Dawg
RavenNuke(tm) Development Team


Joined: Nov 07, 2003
Posts: 910

PostPosted: Sun Jan 28, 2007 10:24 pm Reply with quote

Ok...I had an Idea.....It was a BRAIN fart.....LOL....I need more words on some custom built pages that I use on my site. I would like to display the search results of a query on the page.....NO SEARCH BOX.....just the results.

So my page goes along and then over on the side I list all of the thign availible on my site that goes along with the topic of this page. Lets use a Town as an example.

I have a page about New York.

On the side I would like to display all of the info on my site about New York just like if I had entered that in to my search box on the site.

Has anyone ever done this? Is there a preexisting piece of code to do it?

Thanks!
Dawg
 
View user's profile Send private message
Dawg
PostPosted: Sun Jan 28, 2007 10:38 pm Reply with quote

This is from the search index....

It looks like the query....


[code]if ($category > 0) {
$categ = "AND catid='$category' ";
} else {
$categ = "";
}
$q = "select s.sid, s.aid, s.informant, s.title, s.time, s.hometext, s.bodytext, a.url, s.comments, s.topic from ".$prefix."_stories s, ".$prefix."_authors a where s.aid=a.aid $queryalang $categ";
if (isset($query)) $q .= "AND (s.title LIKE '%$query%' OR s.hometext LIKE '%$query%' OR s.bodytext LIKE '%$query%' OR s.notes LIKE '%$query%') ";
if (!empty($author)) $q .= "AND s.aid='$author' ";
if (!empty($topic)) $q .= "AND s.topic='$topic' ";
if (!empty($days) && $days!=0) $q .= "AND TO_DAYS(NOW()) - TO_DAYS(time) <= '$days' ";
$q .= " ORDER BY s.time DESC LIMIT $min,$offset";
$t = $topic;
$result5 = $db->sql_query($q);
$nrows = $db->sql_numrows($result5);
$x=0;
if (!empty($query)) {
[code]
 
Dawg
PostPosted: Sun Jan 28, 2007 10:40 pm Reply with quote

This looks like the results display....

Code:
if ($nrows>0) {

                        while($row5 = $db->sql_fetchrow($result5)) {
                        $sid = intval($row5['sid']);
                        $aid = stripslashes($row5['aid']);
                        $informant = stripslashes($row5['informant']);
                        $title = stripslashes(check_html($row5['title'], "nohtml"));
                        $time = $row5['time'];
                        $hometext = stripslashes($row5['hometext']);
                        $bodytext = stripslashes($row5['bodytext']);
                        $url = stripslashes($row5['url']);
                        $comments = intval($row5['comments']);
                        $topic = intval($row5['topic']);
         $row6 = $db->sql_fetchrow($db->sql_query("SELECT topictext from ".$prefix."_topics where topicid='$topic'"));
         $topictext = stripslashes(check_html($row6['topictext'], "nohtml"));

                 $furl = "modules.php?name=News&file=article&sid=$sid";
                                $datetime = formatTimestamp($time);
            $query = stripslashes(check_html($query, "nohtml"));
            if (empty($informant)) {
                $informant = $anonymous;
            } else {
                $informant = "<a href=\"modules.php?name=Your_Account&amp;op=userinfo&amp;username=$informant\">$informant</a>";
            }
            if (!empty($query) AND $query != "*") {
                if (eregi(quotemeta($query),$title)) {
               $a = 1;
                }
                $text = "$hometext$bodytext";
                if (eregi(quotemeta($query),$text)) {
               $a = 2;
                }
                if (eregi(quotemeta($query),$text) AND eregi(quotemeta($query),$title)) {
               $a = 3;
                }
                if ($a == 1) {
               $match = _MATCHTITLE;
                } elseif ($a == 2) {
               $match = _MATCHTEXT;
                } elseif ($a == 3) {
               $match = _MATCHBOTH;
                }
                if (!isset($a)) {
               $match = "";
                } else {
               $match = "$match<br>";
                }
            }
                                printf("<tr><td><img src=\"images/folders.gif\" border=\"0\" alt=\"\">&nbsp;<font class=\"option\"><a href=\"%s\"><b>%s</b></a></font><br><font class=\"content\">"._CONTRIBUTEDBY." $informant<br>"._POSTEDBY." <a href=\"%s\">%s</a>",$furl,$title,$url,$aid,$informant);
                                echo " "._ON." $datetime<br>"
                ."$match"
                .""._TOPIC.": <a href=\"modules.php?name=$module_name&amp;query=&amp;topic=$topic\">$topictext</a> ";
            if ($comments == 0) {
                echo "("._NOCOMMENTS.")";
            } elseif ($comments == 1) {
                echo "($comments "._UCOMMENT.")";
                                } elseif ($comments >1) {
                echo "($comments "._UCOMMENTS.")";
            }
            if (is_admin($admin)) {
                echo " [ <a href=\"admin.php?op=EditStory&amp;sid=$sid\">"._EDIT."</a> | <a href=\"admin.php?op=RemoveStory&amp;sid=$sid\">"._DELETE."</a> ]";
            }
            echo "</font><br><br><br></td></tr>\n";
            $x++;
                        }
 
Dawg
PostPosted: Sun Jan 28, 2007 10:45 pm Reply with quote

Code:


$q = "select s.sid, s.aid, s.informant, s.title, s.time, s.hometext, s.bodytext, a.url, s.comments, s.topic from ".$prefix."_stories s, ".$prefix."_authors a where s.aid=a.aid $queryalang $categ";



Sooo....The general idea is to set the varibles to this query.

.....Move Along....Move Along.....Nothing to see here.....

Just me talking to myself. Smile

Am i reading this right?

Dawg
 
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9449
Location: Arizona

PostPosted: Tue Jan 30, 2007 6:31 pm Reply with quote

Ok, couple of considerations:

Are you planning on the module code to control all of this, or are you expecting a block to show these related results?

Whatever is doing the search query will have to know what the "context" is. Not sure how you are planning on doing/knowing that, but you have to know its "New York" vs. "Polish Sausage". LOL But it sounds like you "know" because these are custom pages.

I assume that these pages are some kind of module? If so, then, "yes", you have complete control over the output and you would just need to know what related information you are interested in. But, you need to identify the tables, such as "nuke_stories" that you are showing and you may want to pull in results from more than just one module.

You can also cause this to work with a block by somehow setting a global variable with the "category" that you are interested in that block showing the results for.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Dawg
PostPosted: Tue Jan 30, 2007 9:13 pm Reply with quote

Montego,
I want to set it to what I want in the code. These are setup as simple MODS. No admin. Most of it plain HTML with a little php tossed in here and there.

I want all this html code through the main page and off to one side I would like all the results from the query. I want to set the query in the code. I figured I would start with one catagory, let's say "news" and build from there.

What I am after is the related content that is already on the site to be included on "this page" about "this topic". Does that make sence?

Thanks for the help,

Dawg
 
montego
PostPosted: Wed Jan 31, 2007 6:43 am Reply with quote

Yeah, it makes sense and since you are using PHP for these pages and they are embedded as modules, should be quite easy. I would recommend, though, that since you have multiple pages like this, each with its own criteria, to make the building of the query results a function in a file that you "include" into your PHP scripts so that you do not maintain the same code nn times for nn pages. But, then again, I am sure you already knew that...
 
Dawg
PostPosted: Wed Jan 31, 2007 6:50 am Reply with quote

Do I have the right query for the serch fiunction?

Code:
$q = "select s.sid, s.aid, s.informant, s.title, s.time, s.hometext, s.bodytext, a.url, s.comments, s.topic from ".$prefix."_stories s, ".$prefix."_authors a where s.aid=a.aid $queryalang $categ"; 


If so...I guess all I need to do is go through and set the varible for each piece

s.sid, s.aid, s.informant, s.title, s.time, s.hometext, s.bodytext, a.url, s.comments, s.topic

Is that correct?

Dawg
 
montego
PostPosted: Wed Jan 31, 2007 7:02 am Reply with quote

That really depends upon what you want to show in the results. If all you want is the article title and a bit of the text, then you would only need s.sid (you would always need this because you will want to provide a link from your results to the actual article), s.title and s.hometext. If you only wanted those three, then your query would be simplified to:

$q = "select sid, title, hometext ".$prefix."_stories where $queryalang $categ";

But, you need to formulate the $categ variable to have the properly clauses in it to pull the data that you need.

You have the "raw materials" that you need, but you just need to roll up the sleeves and start giving it a try. Wink

Sounds to me like a good project. Definitely let us know how it goes and ask questions, as needed, if you get stuck (we learn best by doing I believe). Good luck!
 
Dawg
PostPosted: Wed Jan 31, 2007 7:57 am Reply with quote

That is which way I am headed next. I just wanted to make sure I was on the right road before I hit the gas.

Thanks for the help!

Dawg
 
montego
PostPosted: Wed Jan 31, 2007 9:32 am Reply with quote

Most welcome! Can't wait to see the results... BTW, when is it going to be released? tomorrow??? is it tomorrow yet?

ROTFL
 
Dawg
PostPosted: Wed Jan 31, 2007 11:54 am Reply with quote

I will release it.....WHEN IT IS DONE....and not before, which is serveral months AFTER I said I would release it but 2 weeks before I should release it before I can release it after I said I would release it.

Is THAT clear enough DAMNIT!

Shocked Shocked Cool

....Dawg takes out the stick and pokes the sleeping LION....


Last edited by Dawg on Wed Jan 31, 2007 2:47 pm; edited 2 times in total 
montego
PostPosted: Wed Jan 31, 2007 12:14 pm Reply with quote

Oh my God! I nearly fell out of my chair laughing! Laughing ROTFL

Thanks! I needed that!
 
guidyy
Worker
Worker


Joined: Nov 22, 2004
Posts: 208
Location: Italy

PostPosted: Wed Jan 31, 2007 1:16 pm Reply with quote

ROTFLMAO!
 
View user's profile Send private message Visit poster's website MSN Messenger
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6792
Location: Ha Noi, Viet Nam

PostPosted: Wed Jan 31, 2007 1:36 pm Reply with quote

Sounds like a mammoth task you are undertaking here.
I would assume you would be searching content text not just 'title' or 'subject'?
Have you considered how you are going work out 'relevance'? - for example, you might have news or content item of several thousand characters describing Polish Sausage, how they can be cooked, what they taste like etc etc but because the text mentioned in passing "i bought some Polish sasuage in New York and it was horrible", would you consider finding this text 'relevant' when searching for 'New York'?
 
View user's profile Send private message Send e-mail
Dawg
PostPosted: Wed Jan 31, 2007 2:44 pm Reply with quote

Guardian,
On my site I do lots of targeted pages at local Town names. I run News up and down the coast everyday on the front page and have for years.

'relevant' ....I ws going to use whatever logic was in the prebuilt search in Nuke. I am a pretty good cut and paster...but building something like that from scratch is WAY over my head. That is why I was asking about the code in the posts above if I had goitten hold of the right parts and pieces.

I know how to set varibles.....I have an example of the query and an example of the display. I will try to piece it together and see what happens and when it does not work...I will come BEG help from ya'll....LOL!

My Idea was to Key the search to the town name that the page is about and have the last 20 results displayed. Just like if I had used the serch function. I would leave out the authors and all that....just the Title and MAYBE the first X number of words from the text. I will have to play with it to see what works.



Dawg
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©