-
Count elements in a database based on how many unique values there are in a field with MySQL
I had this problem come up when I needed to know how many times a particular essay question had been answered with a written submission. $query = “SELECT COUNT(id) FROM table WHERE essay_id = ‘$essay_id'”; $data = mysqli_query($dbc, $query); $row = mysqli_fetch_array($data); echo $row[‘0′].’ times’; // # times
-
How to keep the carriage return in textarea using PHP?
I’ve created submission forms with the textarea box, but when I echoed out the submission, all the carriage returns disappeared! Of course you don’t want to force the user to type <br /> or <p> tags into the posts. Actually, I learned that the carriage returns did not disappear, you simply need to add a…