473,398 Members | 2,165 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,398 software developers and data experts.

search with a menu list criteria

I lost! with this? any one can suggest me some way to do this?,

Now I try this, past all data bye get , and use the temp var with the
query , but I don't have a good results...

$colname_rs_consulta = "a";
if (isset($_GET['buscar'])) {
$colname_rs_consulta = $_GET['buscar'];
}
if (($_GET['criterio']) == 1) {
$temp = "lb_libros_titulo";
} elseif (($_GET['criterio']) == 2) {
$temp = "lb_libros_autor";
}

echo $temp;
mysql_select_db($database_editorialconn, $editorialconn);
$query_rs_consulta = sprintf("SELECT * FROM lb_libros WHERE '$temp'
LIKE %s", GetSQLValueString("%" . $colname_rs_consulta . "%",
"text"));
$query_limit_rs_consulta = sprintf("%s LIMIT %d, %d",
$query_rs_consulta, $startRow_rs_consulta, $maxRows_rs_consulta);
$rs_consulta = mysql_query($query_limit_rs_consulta, $editorialconn)
or die(mysql_error());
$row_rs_consulta = mysql_fetch_assoc($rs_consulta);

saludos

cana

May 1 '07 #1
1 1542
On May 1, 11:58 am, canagonzales <canagonza...@gmail.comwrote:
echo $temp;
mysql_select_db($database_editorialconn, $editorialconn);
$query_rs_consulta = sprintf("SELECT * FROM lb_libros WHERE '$temp'
LIKE %s", GetSQLValueString("%" . $colname_rs_consulta . "%",
"text"));
$query_limit_rs_consulta = sprintf("%s LIMIT %d, %d",
$query_rs_consulta, $startRow_rs_consulta, $maxRows_rs_consulta);
$rs_consulta = mysql_query($query_limit_rs_consulta, $editorialconn)
or die(mysql_error());
$row_rs_consulta = mysql_fetch_assoc($rs_consulta);
Things are easier to debug when they are coded in a simple way. Try
again and debug with this:

<?php
$colname_rs_consulta = 'a';
if( isset( $_GET['buscar'] ) )
$colname_rs_consulta =
'%'.mysql_real_escape_string( $_GET['buscar'], $editorialconn ).'%';

if( isset( $_GET['criterio'] ) )
{
if( '1' == $_GET['criterio'] )
$temp = 'lb_libros_titulo';

else if( '2' == $_GET['criterio'] )
$temp = 'lb_libros_autor';
}
else
die( 'Criterio es requerido' );

mysql_select_db( $database_editorialconn, $editorialconn );

$query_rs_consulta = "SELECT * FROM `lb_libros` WHERE '$temp' LIKE
'$colname_rs_consulta'";

$query_limit_rs_consulta = "$query_rs_consulta LIMIT
$startRow_rs_consulta, $maxRows_rs_consulta";

$rs_consulta = mysql_query( $query_limit_rs_consulta, $editorialconn )
or die( mysql_error() );

//the following should be in a loop condition
$row_rs_consulta = mysql_fetch_assoc( $rs_consulta );
?>

It is also more efficient without sprintf().

-Mike PII

May 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sean Dodsworth | last post by:
Can anyone tell me how to get a message's number from the message-id using IMAP4.search? I've tried this: resp, items = server.search(None, 'HEADER', '"Message-id"', msgID) but it gives me a...
1
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is three things: 1. Search based on just...
2
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is to search by one ingredient, sometimes by...
4
by: Jan | last post by:
I am having problems trying to print a report based on a form. This is a search form only, no data input. There is a query that the form looks at, but then there are numerous comboxes that you...
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
3
by: Russell | last post by:
Hey, ok i have numerous tables to search through for a 'site search'. some of the searchble fields have html embeded within so after some quick referencing, saw I can use the regExp function...
3
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and...
6
by: shantanu | last post by:
Hi All, I have a requirement to develop a search engine based on some search criteria that will search for the string or statement in all the documents uploaded in the website. The search result...
13
by: Robertf987 | last post by:
Hi, Yet another thing I need help with I'm affraid. I'll first explain what I want, then I'll try to explain what I have. I'm using Microsoft Access 2000. What I want is to be able to do a...
11
by: woodey2002 | last post by:
This problem is driving me crazy. Hello there, i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.