Php $con = mysql_connect("server. Com","user","pswd"); if (!$con) { die('Could not connect: ' . Mysql_error()); } mysql_select_db("db", $con); $result = mysql_query("select count(1) FROM table"); $row = mysql_fetch_array($result); $total = $row0; echo "Total rows: "+$total; mysql_close($con);?
Use COUNT in a SELECT query. $result = mysql_query('SELECT COUNT(1) FROM table'); $num_rows = mysql_result($result, 0, 0).
– CodeGuy Jul 11 at 19:50 Use mysql_result (the best for this instance, IMHO) or one of the similar functions for fetching data from result sets. – Hans Engel Jul 11 at 19:52.
$sql = "select count(column_name) as count from table.
Either use COUNT in your MySQL query or do a SELECT * FROM table and do: $result = mysql_query("SELECT * FROM table"); $rows = mysql_num_rows($result); echo "There are " . $rows . " rows in my table.
1 You're first part is correct. I would emit the last part pulling back the entire dataset. In this questions scope, that's a waste of resources for a simple count.
– George Jul 11 at 19:51 @George I would not suggest using it either. But as he asked if there was any PHP function that could do it, I just shared the option. Just answering the question, I'm not here to teach him how to program.
– Jules Jul 11 at 19:59 And that's fine, however, it's always good to point out potential issues like this when you answer a question. Not only does it help the user understand the differences, it increases the legitimacy of your answer, and the attention it gets. Which means, more points for you!
:) – George Jul 11 at 20:04.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.