I think there is an error in your PHP logic. The line of code before the
while will cause the first row of $result to be retrieved, and will move the
cursor. That first row will never be used because the condition inside the
while will retrieve the next record right away.
$row = mysql_fetch_row($result); /* DELETE THIS ROW */
while ($row=mysql_fetch_row($result)){
By the way, I think I read that using WHERE is more efficient than HAVE.
Regards,
Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032
860.674.8796 / FAX: 860.674.8341
-----Original Message-----
From: Marcelo Fabiani [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 24, 2006 1:38 PM
To: [email protected]
Subject: using like
Hi to all the group, I have a problem with a query using mysql
4.01+mysql+php
This is the form i use to get the data for the query:
<FORM method="post" action="http://www.ibtec.info/resbu.php">
<h1>Ingrese palabra a buscar</h1>
<INPUT type="text" name="ci">
<INPUT type="submit" value="Buscar"> <INPUT type="reset">
</FORM>
and here is the php i use
<?php
$ci=$_POST['ci'];
$link = mysql_connect("localhost", "myuser","mypassword");
mysql_select_db("ibtecin_pagina", $link);
$sql = "SELECT * FROM rubros having nombre like '%$ci%'";
$result = mysql_query($sql, $link);
echo "<table border = '0'> \n";
$row = mysql_fetch_row($result);
while ($row=mysql_fetch_row($result)){
echo "<tr><td>$row[1]</td></tr> \n";
}
echo "</table> \n";
?>
The problem is that if I use one char like for example "a" I get all
that match that criteria,that have that char, but if I want to narrow
the search with more tha one char , for example "aud", and in the table
there is one math "auditoria".
Hope someone can help me, sorry for my english
Regards
Marcelo
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]