Page 1 of 1

Missing a row in query

Posted: Fri Jan 02, 2004 3:36 pm
by webvivre
I have a query that says If I run a quey of number of rows in array) Num_rows is 3 but I am only seeing 2 rows of data (or generically one row less of data than there should be).

Here is an extract of the code...

Code: Select all

// get results
$query = "select * from sffdatafeed where name like "%$trimmed%"  order by name"; // EDIT HERE and specify your table and field names for the SQL query
$result = mysql_query($query) or die("Couldn't execute query");
$row = mysql_fetch_array($result);

// display what the person searched for
echo "<p>You searched for: "" . $var . ""</p>";

// begin to show results set

$count = 1 + $s ;


// now you can display the results returned
  while ($row = mysql_fetch_array($result)) {

echo "<BR><BR><table width='481' border='0' align='center' cellpadding='0' cellspacing='0'>
  <tr>
    <td><table width='481' height='20' border='0' cellpadding='0' cellspacing='0'>
        <tr>
          <td height='18'><img src='images/t_top.gif' width='481' height='29'></td>
        </tr>
      </table>
      <table width='100%' border='0' cellspacing='0' cellpadding='0'>
        <tr>
          <td width='4' background='images/t_left.gif'>&nbsp; </td>
          <td><table border='0' cellspacing='0' cellpadding='0'>
              <tr>
                <td width='168'><table border='0' align='center' cellpadding='0' cellspacing='1'>
                    <tr>
                      <td width='160'><p align='center'>
                      <img src=$row[Thumbnail] border=0 alt="$row[name]"></p></td>
 .......
Any ideas about getting the extra row of data???

Thanks

[Edit: Added PHP tags for eyecandy. --JAM]

Posted: Fri Jan 02, 2004 4:13 pm
by JAM

Code: Select all

$query = "select * from sffdatafeed where name like '%$trimmed%' order by name";
$result = mysql_query($query) or die("Couldn't execute query");
$array = mysql_fetch_array($result); 
print_r($array);
What does this give you?

I can't see any usefull debug information in the code provided.

Posted: Fri Jan 02, 2004 4:17 pm
by webvivre
Get 2 sets of results rather than 3!

Posted: Fri Jan 02, 2004 5:11 pm
by JAM
How do you get num_rows to display 3 then? Verify (and please post if possible) how you get this.

What you fetch using above does not lie, so the error must lie elsewhere. ;)

Posted: Sat Jan 03, 2004 6:28 am
by webvivre
Thanks

The While loop was missing the array[0]