Jump to content

php, read mysql query => $string


Recommended Posts

So, im working on a database driven webpage... a pretty basic setup, search bar with pagination style results... i understand the concept of pagination, but php is kinda goofy at times...

im struggling with pulling "SELECT COUNT(Name) FROM places" from the database with php as a value i can perform some math... how can i pull this from the database as a direct string????

$pagination = ($db -> select("SELECT COUNT(Name) FROM `places`"));
echo serialize($pagination);
155 is the data i need...

here is how i have decided to use the database... http://www.binpress.com/tutorial/using-php-with-mysql-the-right-way/17

example from the site below...

$db = new Db();
$rows = $db -> select("SELECT `name`,`email` FROM `users` WHERE id=5");
Link to comment
Share on other sites

Wouldn't your query produce 1 row with 1 column where "COUNT(Name)" is the column name and "155" is the value?

If, per the example, $rows is what's produced, wouldn't $rows[0] (or some such) contain the value of the first column?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...