niche Posted September 3, 2010 Share Posted September 3, 2010 This works, but is it a proper use of a MySQL Resource? include_once "connect_to_mysql.php";$result = mysql_query("SELECT * FROM location ORDER BY locname") or die(mysql_error()); $var = (mysql_num_rows($result )); Link to comment Share on other sites More sharing options...
Synook Posted September 3, 2010 Share Posted September 3, 2010 Yes - Mysql result resources are used by other Mysql functions for operations specific to that particular query. Why did you think it may have been am improper use? Link to comment Share on other sites More sharing options...
niche Posted September 3, 2010 Author Share Posted September 3, 2010 I thought that I should have tried to use mysql_fetch_array() in some way to get what I needed though I got what I needed without it. I just needed to make sure that I wasn't invoking unintended consequences. Thanks Synook,Niche Link to comment Share on other sites More sharing options...
justsomeguy Posted September 3, 2010 Share Posted September 3, 2010 If the only thing you're trying to get is the count, it's more efficient to have MySQL do the counting instead of returning all of the rows: $result = mysql_query("SELECT COUNT(*) AS num FROM location") or die(mysql_error()); $row = mysql_fetch_assoc($result);$count = $row['num']; Link to comment Share on other sites More sharing options...
niche Posted September 3, 2010 Author Share Posted September 3, 2010 I learn something new here everyday. Thanks justsomeguy. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.