Newbie Spellweaver
- Joined
- Jan 11, 2009
- Messages
- 6
- Reaction score
- 0
Hello,
so.. i need to make a webshop for computer class using SQl and PHP.
we got the database up and running and we can search for products and display them.. but now, we want to show a list of books that aren't available. we got the SQL query and if we run it in phpmyadmin it shows what we want it to show. so we took this query and inserted it into php. (i will include the codes) and we expected that the webpage would show our result.
here is the SQl Query
it shows the following: (i give the url.)
our current php code
our database
it is in dutch so you might not understand it.
hope you guys (girls) can help me out
so.. i need to make a webshop for computer class using SQl and PHP.
we got the database up and running and we can search for products and display them.. but now, we want to show a list of books that aren't available. we got the SQL query and if we run it in phpmyadmin it shows what we want it to show. so we took this query and inserted it into php. (i will include the codes) and we expected that the webpage would show our result.
here is the SQl Query
Code:
SELECT b.nr, b.titel , r.boeknr, r.datum_reservering, r.datum_beschikbaar, r.status
FROM boeken b LEFT JOIN reserveringen r ON r.boeknr = b.nr
WHERE r.status is not null
ORDER BY 'r.boeknr'
it shows the following: (i give the url.)
You must be registered to see links
our current php code
Code:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$db_user = 'h09tsproet';
$db_pass = 'ts06101993';
$db_host = 'localhost';
$db_db = 'h09tsproet_bib';
//connect to host
mysql_connect($db_host,$db_user,$db_pass) or die(mysql_error());
//connect to database
mysql_select_db($db_db) or trigger_error(mysql_error());
//Query
$result = mysql_query("SELECT b.nr, b.titel , r.boeknr, r.datum_reservering, r.datum_beschikbaar, r.status FROM boeken b LEFT JOIN reserveringen r ON r.boeknr = b.nr WHERE r.status is not null ORDER BY 'r.boeknr' limit 0, 131");
$i=0;
while ($i < $num) {
$titel=mysql_result($result, $i,"titel");
$datumres=mysql_result($result, $i, "datum_reservering");
$datumbeschik=mysql_result($result, $i, "datum_beschikbaar");
$status=mysql_result($result, $i, "status");
echo "$titel $datumres $datumbeschik $status";
$i++;
}
?>
our database
You must be registered to see links
it is in dutch so you might not understand it.
hope you guys (girls) can help me out