I have a project for school. I have to create a website, connected to a database. Now, I have a problem with displaying data from my database in/on my webpage.
My database runs/is on a server of my school and created and managed with phpPgAdmin (PostgreSQL).
Here is my code:
Does someone knows the right code to represent the data from my database on my webpage?
<html>
<head>
<link type="text/css" rel="stylesheet" href="index_stylesheet.css"/>
<title>Home</title>
</head>
<body>
<div class="optieBalk">
<ul>
<li><a href="Index.php">Home</a></li>
<li><a href="default.asp">What's New?!</a></li>
<li><a href="login.html">Tickets</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div class="searchbox">
<form action="search.php?searching=true" method="POST">
<input type="text" name="searchcategory" value=""/>
<input type="submit" value="Search"/>
</form>
</div>
<div id="carousel">
<p>
<?php
require 'db_connect.php';
$result=pg_query($conn, "SELECT titel, id FROM film WHERE id=1;");
if (!$result) {
echo "query did not execute";
}
if (pg_num_rows($result) == 0) {
echo "0 records"
}
else {
while ($row = pg_fetch_array($result) {
echo "titel: $row[1] id: $row[0]";
echo "<br />\n";
}
}
?>
</p>
</div>
<div id="footer">
<p id="dateDiv">
</p>
</div>
</body>
</html>
UPDATE* I am able to access my webpage on the server. Now I only need to find out how to show the data from my database ("Kick-ass 2") properly.
http://didactiek1.edm.uhasselt.be/~sebastiaanlagaeysse/index.html
*UPDATE2 I have found the problem, and I can see the content of my database on my webpage :) The file-extension had to be .php on the server in order to execute the php-code, and not .html.