1
neda_barna
search code
  • 2007/9/19 7:33

  • neda_barna

  • Just popping in

  • Posts: 63

  • Since: 2007/9/5 4


hi
i write search for my dictionary
and now i want use in XOOPS
but i dont know what code i must change until use this in xoops
please help me and say me waht code must changes
for example in when i get a word in a textbox ($c= "$_GET[word]";) in XOOPS what must write??
this is search.php












Untitled Document






 


$c"$_GET[word]";


$query="SELECT * FROM tb2,tb4";


if(
trim($_GET[word])!='')


{
   

$query $query " WHERE word LIKE '"trim($_GET[word]) . "%' AND tb2.idF=tb4.idF AND grace='".true."' ";


}


   
$link mysql_connect("localhost","root","");


   if(!
$link) die("couldn't connect to mysql");


   
mysql_query("SET NAMES 'utf8'"$link);


   
mysql_query("SET CHARACTER SET 'utf8'"$link);


   
mysql_query("SET character_set_connection = 'utf8'"$link);


  
//$db_connection_string=mysql_connect("localhost","root","") or die("error :".mysql_error());


   
$database "dic1";


   
mysql_select_db($database) or die("coundn't open $database");


   
$result=mysql_query($query);


 
$my 0;


  
$bgcolor "#E0E0E0"// light gray

    
echo '
'
list of word'


'
;

echo 
'

          
         
       example
      meaning
      word';
while (
$line mysql_fetch_array($resultMYSQL_ASSOC))
  {
  if (
$bgcolor == "#E0E0E0"){
            
$bgcolor "#FFFFFF";
        }else{
            
$bgcolor "#E0E0E0";
        }
$my $my 1;
     echo(
".$bgcolor.">");

     echo 
'.$line["example"].'';

    echo(
"");

    echo 
'.$line["meaning"].'';

    echo(
"");
   
    echo 
'.$line["word"].'';

    echo(
"");
   
    echo(
"");
 }
if(
$my==0)

$query " INSERT INTO `tb6` ( `wait` ) VALUES ( '" $_GET[word] . "');";
mysql_query($query);

}
 echo(
"

");
//echo "";
mysql_free_result($result);
mysql_close($link);
include (
'wait.php');
?>


2
neda_barna
Re: search code
  • 2007/9/19 10:53

  • neda_barna

  • Just popping in

  • Posts: 63

  • Since: 2007/9/5 4


no one can helt me?
i write this project with php
this a dictionary online
this segment is search
i have 2 table
1-idF,word
2-idF,idMF,meaning,example,garce
i want use this project into a xoops
but idont know what of segment must change
please help me

3
zyspec
Re: search code
  • 2007/9/19 13:58

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


Probably the easiest way to do this is to create a simple module that has a block and a "landing page" to show the results.

You'll put the entry form in the block and then pass the results back to the landing page which will display the results (through your 'word' variable).

By the way, don't use this script "as-is" on anthing other than a localhost test site (not connected to anything) without first sanitizing the 'word' variable. As it is right now the script is vulnerable to SQL injection.

This could be done using a custom block and then something like a pagewrap module if you don't want to create your own module. I'd recommend you look at some of the Kaotik documentation that will walk you through creating a simple module. From there you should be able to figure out how to customize it to include your code.

EDIT: You might want to consider going "all the way" and setting up the tables in the database and just use XOOPS to handle all of your connections, authentication, etc. You should be able to pretty easily import your existing data using phpMyAdmin (or similar application).

Login

Who's Online

259 user(s) are online (176 user(s) are browsing Support Forums)


Members: 0


Guests: 259


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits