Jump to content

PHP Help!! - Inverse result of recordset


yandoo

Recommended Posts

Hi there all,

 

If anybody could help me id be most greatful.

 

As you can see in the attachment i have 4 tables that detail the loan of laptops to Teachers, by users.

 

My problem is that when i go to fill in the loan form i have a dynamic drop down menu that details the laptops avaliable for loan. When a laptop is loaned the "completed Y/N" section of the form on the Loan table is entered as N, which means The loan in NOT completed! The loan completed Y/N section is complete when a the laptop is returned.

 

I need to make it so the dynamic drop down menu detailing the avliable laptops only displays the laptops that are avaliable e.g. if they are out on loan "Completed Y/N" (in this case N) they do not appear.

 

When searching for records under  "completed Y/N" (in this case Y) it will display all of the records that have Y in completed section, including those that have previously been loaned and returned. If i search for  "completed Y/N" (in this case N) it displays only the few laptops on loan that have NOT been completed.....But my problem is i need the reverse, of this result. I want these laptop records to be removed from the list, NOT to be the only ones that appear.

 

So....searching for records that are "completed Y/N" (this case N) it would usually display records that are not completed. i need it to NOT display them (N)  and to display the records that have have been completed (e.g. records completed != N)

 

 

Please help me!!

 

 

I realise that i do not necessarly need to base this query around the "completed Y/N" part of Loan form, but am trying for the moment.

 

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/41261-php-help-inverse-result-of-recordset/
Share on other sites

really need to see your code but does this help..

 

<select name="laptop">
<option value="">Choose Laptop..</option>
<?php
$sql = "SELECT * from `laptops` WHERE `completed`='N'";
$result = mysql_query($sql);
while($row = mysql_fetch_object($result)){
?>
<option value="<?=$row->laptop_id;?>"><?=$row->name;?></option>
<? } ?>
</select>

This code is on the Add Loan form, creating dynamic drop down menu from laptop table

 

<select name="LaptopName">

                                <option value="-----------------">-------------------</option>

                                <?php

do { 

?><option value="<?php echo $row_laptopName['LaptopName']?>"><?php echo $row_laptopName['LaptopName']?></option>

                                <?php

} while ($row_laptopName = mysql_fetch_assoc($laptopName));

  $rows = mysql_num_rows($laptopName);

  if($rows > 0) {

      mysql_data_seek($laptopName, 0);

  $row_laptopName = mysql_fetch_assoc($laptopName);

  }

?>

 

 

This bit of code is when querying completed Y/N bit:

 

 

$query_loanI = "SELECT * FROM loan WHERE Complete = 'N' ORDER BY LoanID ASC";

$query_limit_loanI = sprintf("%s LIMIT %d, %d", $query_loanI, $startRow_loanI, $maxRows_loanI);

$loanI = mysql_query($query_limit_loanI, $laptop_loan) or die(mysql_error());

$row_loanI = mysql_fetch_assoc($loanI);

 

if (isset($_GET['totalRows_loanI'])) {

  $totalRows_loanI = $_GET['totalRows_loanI'];

} else {

  $all_loanI = mysql_query($query_loanI);

  $totalRows_loanI = mysql_num_rows($all_loanI);

 

 

 

 

 

Hope this is helpful......

 

Thank You Very much

 

 

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.