Autor Zpráva
Luban
Profil
Prosím o radu. Při poůžití kodu dostanu jen 25 řádků z 276. Čím to může být.
Děkuji
Dodo
<?php
// - This is a complete working dynamic example of using: 
//    odbc_connect, odbc_exec, getting col Names,
//    odbc_fetch_row and no of rows. hope it helps
// - your driver should point to your MS access file

$conn = odbc_connect("P****", "user", "****"); 

$nrows=1; 

if ($conn)
{
$sql =  "SELECT artikelbestand.artnr, artikelbestand.bestand FROM PPSSpol.dbo.artikelbestand artikelbestand WHERE (artikelbestand.artnr Between 100000000 And 199999999) AND (artikelbestand.bestand>0)";
//this function will execute the sql satament
$result=odbc_exec($conn, $sql);

echo "<table  align=\"center\" border=\"1\" borderColor=\"\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr> ";
// -- print field name
$colName = odbc_num_fields($result);
for ($j=1; $j<= $colName; $j++)
{
echo "<th  align=\"left\" bgcolor=\"#CCCCCC\" > <font color=\"#990000\"> ";
echo odbc_field_name ($result, $j );
echo "</font> </th>";
}
$j=$j-1;
$c=0;
// end of field names
while(odbc_fetch_row($result)) // getting data
{
 $c=$c+1;
 if ( $c%2 == 0 ) 
 echo "<tr bgcolor=\"#d0d0d0\" >\n";
 else 
 echo "<tr bgcolor=\"#eeeeee\">\n";
    for($i=1;$i<=odbc_num_fields($result);$i++)
      {        
        echo "<td>";
        echo odbc_result($result,$i);
        echo "</td>";         
        if ( $i%$j == 0 )  
           {
            $nrows+=1; // counting no of rows    
          }   
      }
    echo "</tr>";
} 

echo "</td> </tr>\n";
echo "</table >\n";
// --end of table  
if ($nrows==0) echo "<br/><center> Nothing for $month yet! Try back later</center>  <br/>"; 
else echo "<br/><center> Total Records:  $nrows </center>  <br/>";
odbc_close ($conn);

}
else echo "odbc not connected <br>";
?>
Kajman_
Profil *
Při poůžití kodu dostanu jen 25 řádků z 276. Čím to může být.

Nemůže to být tím, že jen 25 řádků z 276 vyhovuje té podmínce where?
Luban
Profil
To by bylo snadné, té podmínce vyhovuje 276 záznamů z 850.
nightfish
Profil
Luban
takže echo odbc_num_rows($result); ukáže 276?
Kajman_
Profil *
Zkuste před while cyklem nastavit kurzor na počátek dat.

odbc_fetch_row($result, 0);
Luban
Profil
Tak to je na mne moc. Jak to mohu použít ? Píše mi to -1
$result=odbc_exec($conn, $sql);
echo odbc_num_rows($result); 
Kajman_
Profil *
// end of field names
odbc_fetch_row($result, 0); // reset to first row
while(odbc_fetch_row($result)) // getting data
Luban
Profil
Ani to nepomohlo. Ale našel jsem tohle : As some people stated in the ODBC overview, some buggy drivers always return the number of rows to be -1. AFAIK the only way to help this situation is to count the rows by calls to odbc_fetch_into or odbc_fetch_row and then build the table yourself.
Ale nevím jak dál. Po zjednodušení dostávám stále jen 25 řádků
$result=odbc_exec($conn, $sql);
echo odbc_result_all($result);

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0