scheols Posted August 1, 2006 Share Posted August 1, 2006 how does this actually work because i thought it can count rows from database tables or is that possible?well im asking can someone show me an example on how this works and if it can count tables show me how i can count how many topics i have in my DB thanks. Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/ Share on other sites More sharing options...
AndyB Posted August 1, 2006 Share Posted August 1, 2006 http://ca.php.net/manual/en/function.msql-num-rows.phpIt gets the number of rows [b]in the query result[/b]. Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/#findComment-66791 Share on other sites More sharing options...
scheols Posted August 1, 2006 Author Share Posted August 1, 2006 ive read that and its no help like i said in first post can you give me an example Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/#findComment-66793 Share on other sites More sharing options...
AndyB Posted August 1, 2006 Share Posted August 1, 2006 [code]$query = "SELECT * from my_table_name";$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);$numrows = mysql_num_rows($result);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/#findComment-66795 Share on other sites More sharing options...
kenrbnsn Posted August 1, 2006 Share Posted August 1, 2006 [code]<?php$q = "select * from yourtablename";$rs = mysql_query($q) or die("Problem with the query: $q <br>".mysql_error());echo "There are " . mysql_num_rows($rs) . " in the table yourtablename";?>[/code]KenEdit: Beaten by 1 second by AndyB (GMTA) Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/#findComment-66796 Share on other sites More sharing options...
scheols Posted August 1, 2006 Author Share Posted August 1, 2006 so it gets the rows in that tables? basically the number? Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/#findComment-66798 Share on other sites More sharing options...
AndyB Posted August 1, 2006 Share Posted August 1, 2006 Yes. Just like it says in the manual. Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/#findComment-66799 Share on other sites More sharing options...
scheols Posted August 1, 2006 Author Share Posted August 1, 2006 can u do WHERE in the query also? Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/#findComment-66804 Share on other sites More sharing options...
pixy Posted August 1, 2006 Share Posted August 1, 2006 ^ Yes, you can. Like so...$result = mysql_query("SELECT * FROM users WHERE username='user'");if (mysql_num_rows($result) == 1) { echo 'You are in the database!';}else { echo 'Could not find ya.';} Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/#findComment-66805 Share on other sites More sharing options...
scheols Posted August 1, 2006 Author Share Posted August 1, 2006 cool thanks i got my topics on index to rise thanks yalls :)[code=php:0]$s1 = mysql_query("SELECT * FROM topics WHERE fid='$s'");$count = mysql_num_rows($s1);mysql_query("UPDATE forums SET topics='$count' WHERE id='$s' ");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16160-mysql_num_rows/#findComment-66808 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.