CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 HELP! - Include PHP files

Print topic Send  topic

Author Message
Damian
Posted: 05/25/2004, 2:48 AM

I am trying to include a PHP file but the output always ends up either at
the very top of the page or the very bottom.

The current PHP I am trying to include was written by a colleague to do a
better search than what CCS puts out.

Basically I have a Knowlege Base, and I want to search the following fields:
kbase_id
kbase_title
kbase_keywords
kbase_content
kbase_extra

Thats all fine CCS works a treat... but the text that I enter in is searched
exactly as is... ie. searching for "exchange 2003" is different to "2003
exchange".

My colleague has written some PHP to search for ALL the words in ANY of the
fields, and then all combinations of the words in any of the fields. It also
rates the results, ie 100% for all words found, and 3 words out 4 would be
75% etc.

I can post the code if anyone wants to see it....

DaveRexel

Posts: 50
Posted: 05/26/2004, 2:54 PM

::
We've posted a tutorial on including your own functions that could be adapted for your purpose

http://ccs.ath.cx/~ccs/kb.php?language_id=7&category_id=65&event_id=91

Posting the php search code would help in writing a further example.
_________________
/Dave
RexDesign CodeCharge Studio Tutorials
http://rexdesign.com/ccs/
View profile  Send private message
Damian
Posted: 05/27/2004, 10:24 PM

Hi Dave,

I had a look at your tutorial - its a little on the skinny side unless I
missed something!

The link is http://www.itng.com.au/v1/kbresults.php?s_keyword=registry
this now (partially) works after lots of help from CC.
However if two keywords are searched on as in:
http://www.itng.com.au/v1/kbresults.php?s_keyword=exchange+2003

The code Ive added is as follows:
Inside the Pages grid in Design mode I added a label called...
{searchresults}

I have added the following custom code in Before Show on the label:
global $pages;
$output = implode("",
file("http://www.itng.com.au/v1/searchresults.php?s_keyword=".CCGetParam("s_
keyword", "")));
$pages->searchresults->SetValue($output);

I created a file called searchresults.php with the following content:
<? include 'opendb.php';

//$s_keyword1 = $_GET['s_keyword'];

print "<strong>Results for \"$s_keyword\"";
if(($s_keyword))
{
$total_words = count(explode(" ", $s_keyword));
$start_time=getmicrotime();
$query = "
SELECT *,
MATCH( kbase_title, kbase_content, kbase_keywords) AGAINST
('$s_keyword' IN BOOLEAN MODE) AS score
FROM kbase
WHERE MATCH(kbase_title, kbase_content, kbase_keywords) AGAINST
('$s_keyword' IN BOOLEAN MODE) ORDER BY score DESC";
$result = MySQL_query($query);
$end_time = getmicrotime();
print " found in ".(substr($end_time-$start_time,0,5))."
seconds.</strong><BR>";
if(!result)
{
print "Unfortunately the search did not produce any results.";
}
else
{
print '
<table cellspacing="0" cellpadding="3" width="100%" border="0">
<tr>
<td class="nexthostFormHeaderFont" width="100"
bgcolor="#999900">KBase
ID </td>
<td class="nexthostFormHeaderFont"
bgcolor="#999900">Article
Title </td>
<td class="nexthostFormHeaderFont"
bgcolor="#999900">Percentage </td>
</tr>';

while($ans = MySQL_fetch_array($result))
{
$val = $ans['score'];
$val = round(($val/$total_words *100), 1);
//$ans = mysql_fetch_array($result1);
$articleid[$i] = $ans[kbase_id];
//$extract = substr($ans[kbase_content], 0 , 60);
if($val >= 50)
{
print "<tr><td bgcolor=\"#ededed\"><a
href=\"kbdetail.php?kbase_id=$ans[kbase_id]\">$ans[kbase_id]</a></td> <td
bgcolor=\"#ededed\">$ans[kbase_title]</td><td
bgcolor=\"#ededed\">$val</td></tr>";
}
}
}//end if !result

}//end if statement

function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}

?>


We are at the point where we get output, but it cant handle multiple
keywords being sent to it, it is doing the following:
Instead of reading the "exchange+2003+information+store" it is reading it as
it was enterred, "exchange 2003 information store"

Any suggestions anyone?



"DaveRexel" <DaveRexel@forum.codecharge> wrote in message
news:540b5121e3dce3@news.codecharge.com...
> ::
> We've posted a tutorial on including your own functions that could be
adapted
> for your purpose
>
> http://ccs.ath.cx/~ccs/kb.php?language_id=7&category_id=65&event_id=91
>
> Posting the php search code would help in writing a further example.
> _________________
> /Dave
> RexDesign CodeCharge Studio Tutorials
> http://ccs.ath.cx/~ccs/
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

DaveRexel

Posts: 50
Posted: 05/28/2004, 5:01 PM

::
Hi Damian,

The examples serve as starting points for your own adaptation, however we don't use the php print and echo commands in any CCS applications so a simple suggestion would be to use string substitution on the query string to add the + symbols needed by your script.
_________________
/Dave
RexDesign CodeCharge Studio Tutorials
http://rexdesign.com/ccs/
View profile  Send private message
Damian
Posted: 05/28/2004, 11:03 PM

Alex from CC suggested the following, but I am getting a parse error...

In the kbresults_events.php:
$nospaces = str_replace(" ","+",CCGetParam("s_keyword", "");
$output = implode("",
file("http://www.itng.com.au/v1/searchresults.php?s_keyword=".$nospaces));
$pages->searchresults->SetValue($output);

Damian


"DaveRexel" <DaveRexel@forum.codecharge> wrote in message
news:540b7d2da19613@news.codecharge.com...
> ::
> Hi Damian,
>
> The examples serve as starting points for your own adaptation, however we
don't
> use the php print and echo commands in any CCS applications so a simple
> suggestion would be to use string substitution on the query string to add
the +
> symbols needed by your script.
> _________________
> /Dave
> RexDesign CodeCharge Studio Tutorials
> http://ccs.ath.cx/~ccs/
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

DaveRexel

Posts: 50
Posted: 05/29/2004, 6:03 AM

::
Damien,

I suggest that there's a closing bracket missing in this statement

$nospaces = str_replace(" ","+",CCGetParam("s_keyword", "");

amending it as follows might help

$nospaces = str_replace(" ","+",CCGetParam("s_keyword", ""));

_________________
/Dave
RexDesign CodeCharge Studio Tutorials
http://rexdesign.com/ccs/
View profile  Send private message
Damian
Posted: 05/30/2004, 6:18 AM

Hi Dave,

Sorry I hadnt posted an update - that is/was the problem.

Damian

"DaveRexel" <DaveRexel@forum.codecharge> wrote in message
news:540b88a31dceb3@news.codecharge.com...
> ::
> Damien,
>
> I suggest that there's a closing bracket missing in this statement
>
> $nospaces = str_replace(" ","+",CCGetParam("s_keyword", "");
>
> amending it as follows might help
>
> $nospaces = str_replace(" ","+",CCGetParam("s_keyword", ""));
>
> _________________
> /Dave
> RexDesign CodeCharge Studio Tutorials
> http://ccs.ath.cx/~ccs/
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.