Reputation: 5676
<?php $sql = " SELECT e.*, l.counts AS l_counts, l.date AS l_date, lo.counts AS lo_counts, lo.date AS lo_date FROM employee e LEFT JOIN logs l ON l.employee_id = e.employee_id LEFT JOIN logout lo ON lo.employee_id = e.employee_id WHERE e.employee_id =" .(int)$_GET['salary']; $query = mysql_query($sql); $rows = mysql_fetch_array($query); while($countlog = $rows['l_counts']) { echo $countlog; } echo $rows['first_name']; echo $rows['last_name_name']; ?>
I got what I want to my first_name and last_name(get only 1 results). The l_counts I wanted to loop that thing but the result is not stop counting until my pc needs to restart. LoL. How can I get the exact result of that? I only need to get the exact results of l_counts.
Thank you
Jordan Pagaduan
Upvotes: 0
Views: 3000
Reputation: 5312
You are using the assignment operator =
not the comparison operator ==
.
so essentially that line is equal to while(1) { }
what you prob meant to do as @zerkms suggested and loop over the records returned.
edit re: additional OP comments
so to get the 1st row and then loop over the rest
$firstrow = mysql_fetch_array($query);
while($rows = mysql_fetch_array($query)
{
//fun php script
}
Upvotes: 1
Reputation: 1837
$mysqli = new mysqli("localhost", "root", "", "test");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($result = $mysqli->query("DO HERE WHAT YOU WANT TO DO (:")) {
while($row = $result->fetch_row()){
echo $row[0];
}
$result->close();
}
Upvotes: 1
Reputation: 255155
you should loop over rows
, not over $row[key]
while($row = mysql_fetch_array($query)) {
echo $row['l_counts'];
}
Upvotes: 3