Jump to content

php query


justinh

Recommended Posts

<?php 

$query = "

SELECT 

hrclienta.cl_firstname, 

hrclienta.cl_lastname,

    hrhunts.dateofhunt, 
   
    hrhunts.totalcost,

    hrhunts.paidstatus 

    FROM 

    hrclienta, 
   
    hrhunts 

    WHERE 

    (hrclienta.cl_partyid = hrhunts.huntid AND hrclienta.cl_partycontact = 'y')";


    $doit = mysql_query($query) or die(mysql_error()); 

echo "<table width=\"400\" cellpadding=\"20\"><tr><td>Name</td><td>Date Of Hunt</td><td>Total Cost</td><td>Deposit Required</td><td>Paid Status</td></tr>";
while($viewreservation = mysql_fetch_array($doit)){ 

$deposit = number_format($viewreservation['totalcost'], 2, '.', '') / 2; 

 echo "<tr><td>".$viewreservation['cl_firstname']." ".$viewreservation['cl_lastname']."</td><td>".$viewreservation['dateofhunt']."</td><td>".
 $viewreservation['totalcost']."</td><td>".$deposit."</td><td>";


 if($viewreservation['paidstatus'] == "y"){
 echo "<input type=\"button\" value=\"Paid\" class=\"paid\"></td></tr>";
 }else{
 echo "<input type=\"button\" value=\"Not Paid\" class=\"notpaid\"></td></tr>";

 }
 }

 echo "</table>";




     ?>

 

This code works how I want it to if there is only one client in hrclienta with cl.partycontact set to y

but when I add a second one, it displays each row twice =/

 

Any idea why this would happen?

Link to comment
https://forums.phpfreaks.com/topic/144796-php-query/
Share on other sites

Found something out,

 

If I have 2 clients in the hrclienta with cl_partycontact set to y, it displays each of them 2 times.

 

If I have 3 clients in the hrclienta with cl_partycontact set to y, it displays each of them 3 times..

 

etc..

 

 

Any ideas why?

 

Thanks,

justin

Link to comment
https://forums.phpfreaks.com/topic/144796-php-query/#findComment-759816
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.