Jump to content

loop question


dflow

Recommended Posts

i would like to do the following loop:

i have a proposals table

with the following fields:

proposalID

requestID

statusID

 

and a status_list table

statusID

statuslabel

 

get the proposals result by requestID with status label filtered by the each specific row's statusID

proposal#1+STATUSLABEL(BY proposals.statusID)

proposal#2+STATUSLABEL(BY proposals.statusID)

 

how do i approach this?

 

Link to comment
https://forums.phpfreaks.com/topic/174229-loop-question/
Share on other sites

i would like to do the following loop:

i have a proposals table

with the following fields:

proposalID

requestID

statusID

 

and a status_list table

statusID

statuslabel

 

get the proposals result by requestID with status label filtered by the each specific row's statusID

proposal#1+STATUSLABEL(BY proposals.statusID)

proposal#2+STATUSLABEL(BY proposals.statusID)

 

how do i approach this?

 

i got this code together

<?php
$ProposalLists_endRow = 0;
$ProposalLists_columns = 1; // number of columns
$ProposalLists_hloopRow1 = 0; // fit row flag
do {
    if($ProposalLists_endRow == 0  && $ProposalLists_hloopRow1++ != 0) echo "<tr>";
   ?>
                    <td> <a href="edit_proposal_form.php?PropID=<?php echo $row_ProposalLists['ProposalID']; ?>&RID=<?php echo $row_ProposalLists['RequestID']; ?>"><?php echo $row_ProposalLists['ProposalID']; ?>-<?php echo $row_ProposalLists['DepartureDate']; ?>-<?php echo $row_ProposalLists['ReturnDate']; ?>-<?php echo $row_ProposalLists['lanirltd_price_per_night']; ?>--<?php echo $row_StatusDisplay['StatusLabel']; ?><?php echo $row_ProposalLists['StatusID']; ?></a></td>
                    <?php  $ProposalLists_endRow++;
if($ProposalLists_endRow >= $ProposalLists_columns) {
  ?>
                  </tr>
                  <?php
$ProposalLists_endRow = 0;
  }
} while ($row_ProposalLists = mysql_fetch_assoc($ProposalLists));
if($ProposalLists_endRow != 0) {
while ($ProposalLists_endRow < $ProposalLists_columns) {
    echo("<td> </td>");
    $ProposalLists_endRow++;
}
echo("</tr>");
}?>

loop is fine but the status label is not filtered

Link to comment
https://forums.phpfreaks.com/topic/174229-loop-question/#findComment-918479
Share on other sites

add it to the end :)

 

i get an error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\lanirltdcom\backoffice\test.php on line 18

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }


	  $q = mysql_query("SELECT * FROM  proposals JOIN status_list ON (proposals.statusID = status_list.statusID) WHERE proposals.RequestID=2 ");
while ($row = mysql_fetch_assoc($q)) {
  print_r($row);
}


?>
</body>
</html>
<?php
mysql_close($con);
?>

Link to comment
https://forums.phpfreaks.com/topic/174229-loop-question/#findComment-919489
Share on other sites

You shouldn't use WHERE here, as you're already making a filtering comparison. Use AND to add further conditions;

 

        $q = mysql_query("SELECT * FROM  proposals JOIN status_list ON (proposals.statusID = status_list.statusID) AND proposals.RequestID=2 ");

 

Also, you may have problems selecting everything '*' as there are fields in both tables with the same name (you'll probably get this error next).

Link to comment
https://forums.phpfreaks.com/topic/174229-loop-question/#findComment-919775
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.