tags:

views:

115

answers:

3

I have the following queries that work perfectly in MySql:

  1. SELECT * FROM rapoarte WHERE nrtel LIKE '0256%' OR nrtel LIKE '0356%

  2. SELECT * FROM rapoarte WHERE nrtel NOT LIKE '07%' AND nrtel NOT LIKE '0256%' AND nrtel NOT LIKE '0356%'

  3. SELECT * FROM rapoarte WHERE nrtel LIKE '07%'

in PHP they will result the following:

  1. results just for LIKE '0256%'

  2. no results

  3. inclomplete results. i have phone numbers that start with 076, 075 and it only shows the numbers that start with 076.

Anyone know why?

thanks, Sebastian

EDIT

here is the code:

$select_int= mysql_query("SELECT * FROM rapoarte WHERE nrtel LIKE '0256%' OR nrtel LIKE '0356%'");
$local = mysql_fetch_array($select_int);
echo "<table align='center' border='0' width='600'><tr><td><b>Ziua</b></td><td><b>Ora</b></td><td><b>Trunchi</b></td><td><b>interior</b></td><td><b>Durata</b></td><td><b>Numar Format</b></td></tr>";
while($int = mysql_fetch_array($select_int)) {
    echo "<tr>
    <td>".$local['ziua']."</td> 
    <td>".$local['ora']."</td>
    <td>".$local['linie']."</td>
    <td>".$local['interior']."</td>
    <td>".$local['durata2']."</td>
    <td>".$local['nrtel']."</td></tr>";
}
echo "</table>";
+2  A: 
Mark E
i didn't add that part, because i thought it's irrelevant
sebastian
@sebastian - you may want to include that as it's the piece that's not working. Did you try print_r() the array and see if everything is there?
Duniyadnd
A: 

The query you're using in your PHP script doesn't use "LIKE"

Duniyadnd
i posted the wrong code. sorry. i was in a rush.
sebastian
+2  A: 

Hi,

Again...

Here $local = mysql_fetch_array($select_int); you discard your first line. You fetch it and you don't use it.

The second problem is here $int = mysql_fetch_array($select_int). You actually want $local = mysql_fetch_array($select_int) because that's what you use in the while block.

Alin Purcaru
what's the difference between the two versions of the second problem?
sebastian
The variable you're assigning to. Pay attention. In the first case you have `$int` (not used), in the second you have `$local` (what you use in the while loop).
Alin Purcaru