Lodius2000 Posted June 15, 2008 Share Posted June 15, 2008 Hi im looking in a book that uses PDO, I think I can adapt the script to not use PDO, but i need to know what exactly this line would return so that I can adapt it to my needs $total = $db->query('SELECT COUNT(*) FROM table_name')->fetchColumn(0); that being say the table's column 0, (which is the first column, right) is an INT field called id with unique ids starting a 1 and going to 100, 1 id per row could i access the same info with $db = mysql_numrows('SELECT id FROM table_name'); in both cases the query would return 100 right? Link to comment https://forums.phpfreaks.com/topic/110345-do-you-know-pdo-translate-something-form-me/ Share on other sites More sharing options...
corbin Posted June 16, 2008 Share Posted June 16, 2008 that is the same as doing... $q = mysql_query("SELECT COUNT(*) FROM table_name"); $r = mysql_fetch_row($q); $total = $r[0]; Link to comment https://forums.phpfreaks.com/topic/110345-do-you-know-pdo-translate-something-form-me/#findComment-566159 Share on other sites More sharing options...
Lodius2000 Posted June 16, 2008 Author Share Posted June 16, 2008 $total = $r[0]; so is this also true $r = array(q=>0) Link to comment https://forums.phpfreaks.com/topic/110345-do-you-know-pdo-translate-something-form-me/#findComment-566161 Share on other sites More sharing options...
corbin Posted June 16, 2008 Share Posted June 16, 2008 No.... $q is a query resource. mysql_fetch_row takes that resource and returns an array.... What are you even trying to do with q=>0? Link to comment https://forums.phpfreaks.com/topic/110345-do-you-know-pdo-translate-something-form-me/#findComment-566173 Share on other sites More sharing options...
Lodius2000 Posted June 16, 2008 Author Share Posted June 16, 2008 corbin, I guess I dont understand your first reposne then looking further down the script $total is refernced this way print "(Displaying $offset - $lastrownumber of $total)"; this would print something like (going with my 100 rowed example) (Displaying 1-5 of 100) or 5-10 of 100 or 11-15 of 100 depending on what page you were viewing I am making paginated links for my blog Link to comment https://forums.phpfreaks.com/topic/110345-do-you-know-pdo-translate-something-form-me/#findComment-566176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.