Re: [PHP-DB] Number of Lines in Table.
[email protected] (Karl DeSaulniers) Tue, 2 Sep 2014 23:57:13 -0500
| Newsgroups | php.db |
|---|---|
| Message-ID | <[email protected]> |
On Sep 2, 2014, at 9:37 PM, Ethan Rosenberg <[email protected]> wrote: > Dear List - > > This works: > > mysql> describe Purchases; > +-------+-------------+------+-----+---------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +-------+-------------+------+-----+---------+----------------+ > | indx | smallint(6) | NO | PRI | NULL | auto_increment | > | manf | varchar(20) | YES | | NULL | | > | itm | varchar(50) | YES | | NULL | | > | prc | float | YES | | NULL | | > +-------+-------------+------+-----+---------+----------------+ > 4 rows in set (0.00 sec) > > What is my error? > > TIA > > Ethan Hi Ethan, Is it terribly important for you to get the count from MySQL? Php does a nice job of this very easily. $sql = "SELECT itm FROM Purchases"; $result = mysqli_query($cxn, $sql); if (!mysqli_query($cxn, $sql27)) printf("Errormessage: %s\n", mysqli_error($cxn)); if(!$result || (mysql_numrows($result) < 1)){ return NULL; } /* Return result array */ $rowarray = mysqli_fetch_array($result); $numrows = count($rowarray); //return $rowarray; print_r('Number of rows: '.$numrows); print_r('Results { '.$row.' }'); Haven't tested this, but I believe it should work out the box. May need to tweek to taste. HTH, Best, Karl DeSaulniers Design Drumm http://designdrumm.com