Re: Number of Lines in Table.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sep 2, 2014, at 9:37 PM, Ethan Rosenberg <erosenberg@xxxxxxxxxxxxxxxxxxxx> 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


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux