Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP Having problem involving getting database content to show up after passing a query string.

Hello, I have been stuck on this and figured I would come here to seek assistance. The main objective of this project is to create an intranet and have the employee name link to a details.php which displays details about that specific employee. the problem I am having is that whenever I click on the employee name, it displays the text in the else statement rather than the text within the if statement. What are some ways I can remediate the issue?

Code below:



details.php:
<!DOCTYPE html> <html lang="en"> <head> </head> <body> <div class = "navigation"> <a href = "index.php"> Employees</a> </div> <?php require 'dbConn.php'; echo "<br>"; $employeeid = $_GET['employeeid']; $sql = 'SELECT e.employee_id, e.last_name, e.first_name, e.email, e.phone_number, d.department_name, j.job_title, e.hire_date, e.salary, d.location_id, l.city, l.state_province, l.country_id FROM employees as e, departments as d, jobs as j, locations as l WHERE e.employee_id = $employeeid and e.department_id = d.department_id and e.job_id = j.job_id and d.location_id = l.location_id ORDER by e.last_name'; $result = $mysqli->query($sql); $output = array($sql); if ($result !== false && $result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $output = array($row["first_name"] . $row["last_name"] . "<br>" . $row["job_title"] . $row["hire_date"]); } } else { echo "0 results"; } $mysqli->close(); ?> </body> </html>
 
Have you tried echoing out the SQL query you are running and pasting it directly into your database program? If you get zero results when you are expecting a result that would cause the else to trip. Also, a syntax error in the query would also be treated like a no-result.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom