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
&#65279;<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">


<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<title>Untitled Document</title>


</head>



<body> 


<?php
$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 '<br><p dir="rtl"><font face="Tahoma" size="4"><b>'list of word'</b></font></p><br>';

echo 
'<div align="center"><center><table border="0"  bordercolor="#111111" width="80%">
          <tr bgcolor=#E0E0E0 align= center>
         
       <td><font face="Tahoma" size="2"><b>example</b></font></td>
      <td><font face="Tahoma" size="2"><b>meaning</b></font></td>
      <td><font face="Tahoma" size="2"><b>word</b></font></td>'
;
while (
$line mysql_fetch_array($resultMYSQL_ASSOC))
  {
  if (
$bgcolor == "#E0E0E0"){
            
$bgcolor "#FFFFFF";
        }else{
            
$bgcolor "#E0E0E0";
        }
$my $my 1;
     echo(
"<tr bgcolor=".$bgcolor."><td align= center>");

     echo 
' <font face="Tahoma" size="2">'.$line["example"].'</font>';

    echo(
"</td><td align= right>");

    echo 
' <font face="Tahoma" size="2">'.$line["meaning"].'</font>';

    echo(
"</td><td align= right>");
   
    echo 
' <font face="Tahoma" size="2">'.$line["word"].'</font>';

    echo(
"</td><td align= right>");
   
    echo(
"</td></tr>");
 }
if(
$my==0)

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

}
 echo(
"</table></center></div><center><br>");
//echo "</table>";
mysql_free_result($result);
mysql_close($link);
include (
'wait.php');
?>
</body>
</html>

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

167 user(s) are online (113 user(s) are browsing Support Forums)


Members: 0


Guests: 167


more...

Donat-O-Meter

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

Latest GitHub Commits