i have this table:
+--+----------+
| page_id | url |
+--+------------+
| 1 | page_1.php |
+--+------------+
| 2 | page_2.php |
+--+------------+
| 3 | page_3.php |
+--+------------+
I want to create a php counter that gets the number of rows in the page_id field, adds them together and then adds one to the answer.
ie. from the table above it would count the rows and come out with 3. then it would add one to it and return the answer of 4.
something like:
$page_id_counter = 0;
then get the code to count the rows. and then:
$page_id_counter = $page_id_counter + 1;
Can anybody suggest a way of doing this? Or alternatively a better method of doing the same sort of thing?
mysql/php count rows
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: mysql/php count rows
Code: Select all
SELECT COUNT(page_id)+1 AS `count` FROM `yourtable`Not exactly sure what you described
Re: mysql/php count rows
thanks that's what I meant exactly!