NameSilo

Need simple line of Php / Mysql code

Spaceship Spaceship
Watch

Alex.

Account Closed
Impact
5
[resolved] Need simple line of php / mysql code

hi,
i have litterally started learning php today, and im trying to compile a simple script.

i nèed a line of php code that returns the no. of rows in a table.

if i get this before 7:30pm (40 mins @ time of writing) i will donate the author 10np.

i know thats not a lot, but im not asking much.
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
From php website
http://us3.php.net/mysql_num_rows

Code:
<?php

$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $link);

$result = mysql_query("SELECT * FROM table1", $link);
$num_rows = mysql_num_rows($result);

echo "$num_rows Rows\n";

?>
 
0
•••
Here you go sir.

PHP:
// You should have the following line.. 
$result = mysql_query($sql);

// This is the line you want to get the rows:
$rows = mysql_num_rows($result);

$rows will store how many rows the query has. Hence the rows stored in $result

Regards,
Richard.
 
0
•••
thanks.
thats all i need
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back