I show a rowset for each car that I have in my database. Each line has a form field where a registered user can send an offer. When the user has made an offer for any car, the form field is replaced by text that displays the cost of the submitted proposal.
What I experience, however, is a less than ideal result. If I make a suggestion for one line, fine, the logic works. If I make another suggestion for another line, then the logic will work, except for the fact that the previous line now displays the form again.
I can provide more detailed information if necessary, but maybe someone is already familiar with this.
Thanks in advance.
<?php require("db-connect.php"); $display = "SELECT filename, car_id, make, model, year, mileage, vin, description, GROUP_CONCAT(filename) FROM scraplis_cars LEFT JOIN scraplis_images USING (car_id) GROUP BY car_id ORDER BY date_time DESC"; $dResult = mysql_query($display) or die('error:' . mysql_error()); $offer = "SELECT car_id, user_id, offer_id, value FROM scraplis_offers WHERE user_id = '".$_SESSION['user_id']."'"; $oResult = mysql_query($offer) or die('Error ' . mysql_error()); $oRow = mysql_fetch_array($oResult); if(!isset($_SESSION['access'])){ header("location:index.php"); } ?> <?php if($dResult): ?> <table class="post"> <thead> <tr> <?php if(isset($_SESSION['email']) && $_SESSION['access'] == 0) : ?> <th scope="col">Images</th> <th scope="col">Make</th> <th scope="col">Model</th> <th scope="col">Year</th> <th scope="col">Mileage</th> <th scope="col">VIN #</th> <th scope="col">Description</th> <th scope="col">Offer</th> </tr> </thead> <tbody> <?php while($dRow = mysql_fetch_array($dResult)) : ?> <?php $str = $dRow[8]; ?> <?php $images = explode(',', $str); ?> <tr> <td> <ul> <?php if(!empty($str)) : ?> <?php foreach($images as $value) :?> <li> <a href="images/<?php echo $value; ?>" rel="lightbox[<?php echo $row['car_id']; ?>]"> <img src="images/<?php echo $value; ?>"/> </a> </li> <?php endforeach; ?> <?php endif; ?> <ul> </td> <td><?php echo $dRow['make']; ?></td> <td><?php echo $dRow['model']; ?></td> <td><?php echo $dRow['year']; ?></td> <td><?php echo number_format($dRow['mileage']); ?></td> <td><?php echo $dRow['vin']; ?></td> <td><span><?php echo $dRow['description']; ?></span></td> <td> <?php if($oRow['car_id'] == $dRow['car_id']) : ?> Offer pending approval - $<?php echo $oRow['value']; ?> <?php else : ?> <form id="offer" method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <input type="text" id="price" name="offer" /> <input type="hidden" name="submitted" value="<?php echo $dRow['car_id']; ?>" /> <input type="submit" name="price" value="Submit" /> </form> <?php endif; ?> </td> </tr> <?php endwhile; ?> <?php else : ?> <th scope="col">Delete</th> <th scope="col">Images</th> <th scope="col">Make</th> <th scope="col">Model</th> <th scope="col">Year</th> <th scope="col">Mileage</th> <th scope="col">VIN #</th> <th scope="col">Description</th> </tr> </thead> <tbody> <?php while($dRow = mysql_fetch_array($dResult)) : ?> <?php $str = $dRow[8]; ?> <?php $images = explode(',', $str); ?> <tr> <td> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <input type="checkbox" name="record" value="<?php echo $row['car_id']; ?>" /> <input type="submit" name="delete-car" value="Delete" /> </form> </td> <td> <ul> <?php if(!empty($str)) : ?> <?php foreach($images as $value) :?> <li> <a href="images/<?php echo $value; ?>" rel="lightbox[<?php echo $row['car_id']; ?>]"> <img src="images/<?php echo $value; ?>"/> </a> </li> <?php endforeach; ?> <?php endif; ?> </ul> </td> <td><?php echo $dRow['make']; ?></td> <td><?php echo $dRow['model']; ?></td> <td><?php echo $dRow['year']; ?></td> <td><?php echo number_format($dRow['mileage']); ?></td> <td><?php echo $dRow['vin']; ?></td> <td><span><?php echo $dRow['description']; ?></span></td> </tr> <?php endwhile; ?> <?php endif; ?> </tbody> </table> <?php endif; ?>
source share