[Solved] Use PHP to render multiple images to the browser [closed]

[ad_1] You use a while loop in to fetch the results. $coverpic=””; $sql = “SELECT filename FROM photos WHERE user=”$u””; $query = mysqli_query($db_conx, $sql); if(mysqli_num_rows($query) > 0){ while($row = mysqli_fetch_row($query)) { $filename = $row[0]; $coverpic .= ‘<img src=”https://stackoverflow.com/questions/16442747/user/”.$u.”https://stackoverflow.com/”.$filename.'” alt=”pic”>’; //notice the .= to append to the string instead of overwrite } } But if you … Read more

[Solved] joins in MySQL for leave management in PHP and MySQL [closed]

[ad_1] Let’s take it step-by-step… First, the entities you’re selecting are in the leave_request table. So let’s start there: SELECT leave_request.* FROM leave_request Now, you need to know the data for the applied_by column in the desired results. So you join the staff table: SELECT applied_staff.name AS applied_by FROM leave_request INNER JOIN staff AS applied_staff … Read more

[Solved] How to properly optimise mysql select statement

[ad_1] Unless there’s more to the picture, why not just query everything, ordered by section, to have the A-Z: SELECT * FROM Main_Section ORDER BY section … and then process the results with one loop, which could look something like this: $sections = $connect->query(“SELECT * FROM Main_Section ORDER BY section”); while ($row = $sections->fetch_array()) { … Read more

[Solved] Php, mysql coding error

[ad_1] You are getting that error simple because you are using a newer version of php that does not support mysql_* functions, those functions have been depreciated and completely removed from the latest version of php. You should use mysqli prepared functions or pdo prepared statements. using mysqli to connect to database you will use … Read more

[Solved] Why is it saying no database selected?

[ad_1] Your final code should be identical to: <?php $con = mysqli_connect(“localhost”, “root”, “”, “radian”); if (!$con) { exit(“Couldn’t connect: ” . mysqli_connect_error()); } mysqli_set_charset($con, “utf8”); $insert_data = “UPDATE enquiries SET ResponseDate=”” . $current_date . “”, Response=”” . $txtResponse . “”,Enquiry_No = ‘” . $_SESSION[‘ses_staff’] . “‘ WHERE Enquiry_No = ‘” . $txtStudentId . “‘”; … Read more

[Solved] mySQL Largest number by group

[ad_1] In general ORDER BY in a sub-query makes no sense. (It only does when combined with FETCH FIRST/LIMIT/TOP etc.) The solution is to use a correlated sub-query to find the heaviest fish for the “main query”‘s current row’s username, location, species combination. If it’s a tie, both rows will be returned. SELECT * FROM … Read more

[Solved] most efficient way to write this sql query?

[ad_1] This is a little more difficult because MySQL doesn’t have Row_Number() so you’ll need to simulate it. One way is use a self join and a count. You could also use the @rownumber technique described here In my example I used animal_id to find the most recent but you may want to change the … Read more