473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help using XAjax

60
I need some help. I want to make a search engine using Ajax, so i came across XAjax. And also tried AdoDB, for the pager.

So, here it is:

[PHP]<?php
require_once("xajax/xajax_core/xajax.inc.php");
require_once("adodb/adodb.inc.php");
require_once("adodb/adodb-pager.inc.php");

$xajax = new xajax();
$xajax->registerFunction("buscar");

function buscar($ca, $cr, $tx, $nm){
if(empty($_POST['st']) && $ca == "" && $tx !== "" && $cr !== ""){
$r = "SELECT * FROM material WHERE `$cr` LIKE '%$tx%'";
}else{
if($tx == "" && $cr == "" && $ca == ""){
$r = "SELECT * FROM material";
}elseif($tx == "" && $cr == "" && $ca !== ""){
$rt = "SELECT * FROM material WHERE `tipo`='$ca'";
}elseif($ca == "" && $tx !== "" && $cr !== ""){
$r = "SELECT * FROM material WHERE `$cr`='$tx'";
}
}

$db = NewADOConnection('mysql');
$db->Connect('localhost', 'root-user', 'heregoesthepass', 'oblig');
$pager = new ADODB_Pager($db, $r);
$pager->Render($nm);

$objResponse = new xajaxResponse();
$objResponse->addAssign("SomeElementId","innerHTML", $newContent);
return $objResponse;
}
$xajax->processRequests();
$xajax->printJavascript();
?>[/PHP]

The sql queries are OK, but i am almost sure that the Xajax part isn't.

p.s: It is possible to use both AdoDB and XAjax at the same tiem like i did right ??
Aug 2 '07 #1
9 1518
pplers
60
this the new one:

[PHP]<?php
require_once("xajax/xajax_core/xajax.inc.php");
require_once("adodb/adodb.inc.php");
require_once("adodb/adodb-pager.inc.php");

$xajax = new xajax();
$xajax->registerFunction("buscar");

function buscar($ca, $cr, $tx, $nm){
if(empty($_POST['st']) && $ca == "" && $tx !== "" && $cr !== ""){
$r = "SELECT * FROM material WHERE `$cr` LIKE '%$tx%'";
}else{
if($tx == "" && $cr == "" && $ca == ""){
$r = "SELECT * FROM material";
}elseif($tx == "" && $cr == "" && $ca !== ""){
$rt = "SELECT * FROM material WHERE `tipo`='$ca'";
}elseif($ca == "" && $tx !== "" && $cr !== ""){
$r = "SELECT * FROM material WHERE `$cr`='$tx'";
}
}

$db = NewADOConnection('mysql');
$db->Connect('localhost', 'root-user', 'p3jvkkj0k', 'oblig');
$pager = new ADODB_Pager($db, $r);
$newContent = $pager->Render($nm);

$objResponse = new xajaxResponse();
$objResponse->addAssign("answer","innerHTML", $newContent);
return $objResponse;
}
$xajax->processRequest();

?>[/PHP]

Expand|Select|Wrap|Line Numbers
  1. <html><head></head><body><br><br><br>
  2. <form method=POST name="fer">
  3.         Crit.: <select size=1 name=cri onMouseOver="this.style.backgroundColor='#99CCFF'" onMouseOut="this.style.backgroundColor=''"><option></option><option value=id>ID</option><option value=titulo>Título</option><option value=autor>Autor</option><option value="func_actual">Funcionario dueño</option></select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  4.         Category: <select size=1 name=cat onMouseOver="this.style.backgroundColor='#FF9966'" onMouseOut="this.style.backgroundColor=''"><option></option><option value=CD>CD's</option><option value=Documento>Documentos Impresos</option><option value=DVD>DVD's</option><option value=Libro>Libros</option><option value=Revista>Revistas</option></select><br><br>
  5.         Search for: <input type=text name=sch onMouseOver="this.style.backgroundColor='#CCCCCC'" onMouseOut="this.style.backgroundColor=''">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  6.         Results per page: <input type=text name=val maxlength=3 size="1" value=10 onMouseOver="this.style.backgroundColor='#00CC33'" onMouseOut="this.style.backgroundColor=''"><br>
  7.         <center><input type=radio name=st><b>Strict search ???</b><br><br>
  8.         <input type=button value="Search" onMouseOver="this.style.backgroundColor='blue'" onMouseOut="this.style.backgroundColor=''" onClick="<? $xajax->printJavascript(); ?>"></center></form><br><br><br><br>
  9.         <p id=answer></p>
  10. </body></html>
Aug 2 '07 #2
pplers
60
can someone help ???
Aug 4 '07 #3
pbmods
5,821 Expert 4TB
Heya, pplers.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Aug 5 '07 #4
pplers
60
the poblem is the ADODB part. As you can see, the sql query uses variables passed through GET. It's ok for the first page but then, the ADODB PAGER only passes one variable through GET and by default is adodb_page_number=X or something like that...
Aug 6 '07 #5
pbmods
5,821 Expert 4TB
Heya, pplers.

I noticed that you set the form's action to post. Is this intentional?
Aug 6 '07 #6
pplers
60
Yes, sorry. In my script it's GET so the error still continues...
Aug 6 '07 #7
pbmods
5,821 Expert 4TB
Heya, pplers.

Where are the variables such as $cr, $tx, etc. defined?
Aug 6 '07 #8
pplers
60
As i said in a previous post, (almost) all the vars are from a GET form


p.s: I want to know if there's a way to avoid using SESSIONS (i tried them and they worked great)
Aug 6 '07 #9
pbmods
5,821 Expert 4TB
Heya, pplers.

As i said in a previous post, (almost) all the vars are from a GET form
So then you have register_globals turned on?

p.s: I want to know if there's a way to avoid using SESSIONS (i tried them and they worked great)
You tried them, and they worked great, but you don't want to use them. *bowf*?
Aug 6 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: mattigiat | last post by:
Sorry for being such a newbie in this respect, but here's my question: I have Visual Studio, with VB6 ent., with msdn help installed. Is there any way to downgrade to just using the VB5 help, on...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
5
by: Steve Teeples | last post by:
Can someone point me to a document that clearly identifies the steps of creating a good help system for an application? I have a test tool that I'd like to add help to so that others will know how...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: geshan | last post by:
Hello all, I'm having trouble populating a select box as per the selection of above select box.Its like level 2 select box depends on the value of level 1 box. Both the boxes values come from a...
7
by: afraze | last post by:
I want to use static variable in xajax but always, it executes only one time.. When i call again, value of static variable isn't changing how can i fix the problem? or how can i use static...
3
by: nathanwb | last post by:
I have the following php code, at the top I am pulling a piece of data from a query and I echo the results with no problem, I am using Ajax with this page as well and further down the page when I...
6
by: priyajohal | last post by:
#include<fstream.h> #include<process.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<dos.h> #include<ctype.h> #include<stdio.h> void setup() void help();
6
by: Bob M | last post by:
Fellow php'ers; I am trying to make a call to a js function from within a php function based on the selected value of an HTML select statement (whew!). While the server side php program is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.