•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,533 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,886 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1535 | Replies: 19 | Solved
![]() |
•
•
Join Date: Aug 2007
Posts: 181
Reputation:
Rep Power: 0
Solved Threads: 0
Mr. fatihpiristine, thank u much for the attachment, but there is a misunderstanding...I have the below problem...
I want to create a program for LIBRARY, I faced to problem on depositing book section (Giving book to someone), in this section there is a combo which should contian the books name, maybe we have from one book two, three (Quantity), if one of them given to some one then one should be less than Book Quantity, and if all of them given for deposit, then in the combo the name of that book must not appear, so I did this in MS ACCESS, now want to have this in PHP and MySQL, so I did the following but I dont know what is the problem:
$qryDepositedBooks = select("SELECT tblDeposit.bookId AS [Book ID], Last(tblDeposit.depositId) AS [Last Deposited Book], Count(tblDeposit.depositId) AS [Total Deposited Book], tblBook.bookQuantity, tblDeposit.isBookReturn
FROM tblBook LEFT JOIN tblDeposit ON tblBook.bookId = tblDeposit.bookId GROUP BY tblDeposit.bookId, tblBook.bookQuantity, tblDeposit.isBookReturn HAVING (((tblDeposit.isBookReturn)=0))");
$qryDepositedBooksForPersonnel = select("SELECT tblDeposit.* FROM $qryDepositedBooks LEFT JOIN tblDeposit $qryDepositedBooks.[Last Deposited Book] = tblDeposit.depositId");
$qryBooksReadyForDeposit = select("SELECT tblBook.bookName, tblBook.bookId, $qryDepositedBooks.[Total Deposited Book], $qryDepositedBooksForPersonnel.isBookReturn FROM (tblBook LEFT JOIN $qryDepositedBooks ON tblBook.bookId = $qryDepositedBooks.[Book ID]) LEFT JOIN $qryDepositedBooksForPersonnel ON tblBook.bookId = $qryDepositedBooksForPersonnel.bookId WHERE ((($qryDepositedBooks.[Total Deposited Book])<([tblBook]![bookQuantity]) Or ($qryDepositedBooks.[Total Deposited Book]) Is Null)) OR ((($qryDepositedBooksForPersonnel.isBookReturn)=1)) ORDER BY $qryDepositedBooks.[Total Deposited Book] DESC");
// $qryDepositedBooks, $qryDepositedBooksForPersonnel , $qryBooksReadyForDeposit as you see I created these queries, but I dont know how to use them with each other queries
in combo section:
<td><select name="cboBook" id="cboBook">
<option></option>
<?php
for($i=0;$i<mysql_num_rows($qryBooksReadyForDeposit);$i++)
{
$b_code=mysql_fetch_assoc($qryBooksReadyForDeposit);
?>
<option value="<?php print($b_code['bookId']); ?>"><?php print($b_code['bookName']); ?></option>
<?php
}
?>
</select></td>
Just in this combo I want to see the bookName from $qryBooksReadyForDeposit, nothing more...
need your guide...
I want to create a program for LIBRARY, I faced to problem on depositing book section (Giving book to someone), in this section there is a combo which should contian the books name, maybe we have from one book two, three (Quantity), if one of them given to some one then one should be less than Book Quantity, and if all of them given for deposit, then in the combo the name of that book must not appear, so I did this in MS ACCESS, now want to have this in PHP and MySQL, so I did the following but I dont know what is the problem:
$qryDepositedBooks = select("SELECT tblDeposit.bookId AS [Book ID], Last(tblDeposit.depositId) AS [Last Deposited Book], Count(tblDeposit.depositId) AS [Total Deposited Book], tblBook.bookQuantity, tblDeposit.isBookReturn
FROM tblBook LEFT JOIN tblDeposit ON tblBook.bookId = tblDeposit.bookId GROUP BY tblDeposit.bookId, tblBook.bookQuantity, tblDeposit.isBookReturn HAVING (((tblDeposit.isBookReturn)=0))");
$qryDepositedBooksForPersonnel = select("SELECT tblDeposit.* FROM $qryDepositedBooks LEFT JOIN tblDeposit $qryDepositedBooks.[Last Deposited Book] = tblDeposit.depositId");
$qryBooksReadyForDeposit = select("SELECT tblBook.bookName, tblBook.bookId, $qryDepositedBooks.[Total Deposited Book], $qryDepositedBooksForPersonnel.isBookReturn FROM (tblBook LEFT JOIN $qryDepositedBooks ON tblBook.bookId = $qryDepositedBooks.[Book ID]) LEFT JOIN $qryDepositedBooksForPersonnel ON tblBook.bookId = $qryDepositedBooksForPersonnel.bookId WHERE ((($qryDepositedBooks.[Total Deposited Book])<([tblBook]![bookQuantity]) Or ($qryDepositedBooks.[Total Deposited Book]) Is Null)) OR ((($qryDepositedBooksForPersonnel.isBookReturn)=1)) ORDER BY $qryDepositedBooks.[Total Deposited Book] DESC");
// $qryDepositedBooks, $qryDepositedBooksForPersonnel , $qryBooksReadyForDeposit as you see I created these queries, but I dont know how to use them with each other queries
in combo section:
<td><select name="cboBook" id="cboBook">
<option></option>
<?php
for($i=0;$i<mysql_num_rows($qryBooksReadyForDeposit);$i++)
{
$b_code=mysql_fetch_assoc($qryBooksReadyForDeposit);
?>
<option value="<?php print($b_code['bookId']); ?>"><?php print($b_code['bookName']); ?></option>
<?php
}
?>
</select></td>
Just in this combo I want to see the bookName from $qryBooksReadyForDeposit, nothing more...
need your guide...
Last edited by tanha : Oct 19th, 2007 at 4:19 am.
sorry.. i dont have time to code that pages again. i deleted them already. as far as i remember,
i saved a php file called readytodeposit, it lists the books which are ready to deposit.. ( and drops the numbers of deposited books from the initial quantity... // ig: u have 20 same books. each time it drops one. as you wanted. if the quantity to deposit = 0 then, you will not the name of the book.
i did everything in sql query if you read the codes you will understand.
your sql syntax has many problems... do not try to post such that sql query syntax via php files.. you ll get error..
i saved a php file called readytodeposit, it lists the books which are ready to deposit.. ( and drops the numbers of deposited books from the initial quantity... // ig: u have 20 same books. each time it drops one. as you wanted. if the quantity to deposit = 0 then, you will not the name of the book.
i did everything in sql query if you read the codes you will understand.
your sql syntax has many problems... do not try to post such that sql query syntax via php files.. you ll get error..
Last edited by fatihpiristine : Oct 19th, 2007 at 7:36 am.
Do a favour, leave me alone
•
•
Join Date: Aug 2007
Posts: 181
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks a world from Mr. fatihpiristine providing this code for me, this is exactly what I wanted to do...Thanks again
<?php
$qryDepositedBooks = select("
SELECT
tblbook.bookId,
tblbook.bookCode,
tblbook.bookStore,
tblbook.bookName,
lstsubject.subName,
tblbook.bookQuantity,
tblbook.bookQuantity - (select count(tbldeposit.depositId) from tbldeposit where tblbook.bookId = tbldeposit.bookId ) as Deposited
from tblbook, lstsubject
where
tblbook.bookSubject = lstsubject.subId and
( tblbook.bookQuantity - (select count(tbldeposit.depositId) from tbldeposit where tblbook.bookId = tbldeposit.bookId ) ) > 0
");
?>
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Sending pic attachments via PHP form (PHP)
- PHP Form, SQL connectivity issues, please help. (MySQL)
- help with php and javascript (PHP)
- Issue with the LIKE expression and php (PHP)
- Please help me out with MySQL query (MySQL)
- Help with a smyql query and php (MySQL)
- php connection to mysql headache (PHP)
- PHP/SQL query help (PHP)
- I had a experience of a website coded in PHP (PHP)
- Retreiving variables from a sql query into a form (PHP)
Other Threads in the PHP Forum
- Previous Thread: 7x7 Forced Matrix Script
- Next Thread: How to insert new line character


Linear Mode