Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Learning Aids/Tools 2 years ago
Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I am trying to retrieve the row count from a mysql database and display it into a textview in android. I have the following php file:
php error_reporting(E_ALL ^ E_DEPRECATED); $con = mysql_connect('localhost', 'root', ''); mysql_select_db('valetdb', $con); $result = mysql_query("select count(*) FROM drivers where datetimeparkreq is not null"); $row = mysql_fetch_array($result); $total = $row[0]; echo "Total rows: " . $total; ?>
I was hoping to get the data from the line "$total = $row[0];". Since it does hold the count of rows. I am still learning about this whole json android php connection thing. So I would appreciate if someone will aid me! Thanks!
Paolo, As the comments suggest, you should use something like the mysqli commands rather than mysql commands in php. The mysqli command to get the number of rows in a query result is mysqli_num_rows(). If you are looking to send this information to an Android app, the json format is very convenient to use. If you are sending just one piece of data, you could use php code like:
echo "{numrows:";
echo $total . "}";
On the android side you would use HttpURLConnection and related routines to send a get request to the website and JsonReader routines to parse the json object sent from the website. Hopefully this helps you get started on communicating with your website.
Mike Kagan
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.