#
#
#
#
#
#
#
#
#
# get settings
require "settings.php";
require "core-settings.php";
require "libs/ext.lib.php";
# decide what to do
if (isset($_GET["id"])) {
    $OUTPUT = show_question($_GET["id"]);
} elseif (isset($_POST["key"])) {
    switch ($_POST["key"]) {
        case "confirm":
            $OUTPUT = results_db();
            break;
        default:
            $OUTPUT = search_db();
    }
} else {
    # Display default output
    $OUTPUT = search_db();
}
# Get templete
require "template.php";
function search_db()
Example #2
0
<head>
<title>Stack Exchange</title>
<link href='https://fonts.googleapis.com/css?family=Lato:400,300,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
	<div class="header">
		<center><h1><a href="index.php">Simple StackExchange</a></h1></center>
	</div>
	<div class="content">
		<center><form action="search.php" method="post">
			<input type="text" name="search" size="100" style="height:25px">
			<button type="submit" style="display: inline-block; height:30px">Search</button>
		</form>
		Cannot find what you're looking for? Ask <a href="form.php?idx=1" style="color: #FF8000;">here</a>.
		</center>

		<h2>Recently Asked Questions</h2>
		<?php 
include "function/database.php";
$conn = connect_database();
$sql = "SELECT * FROM `question` ORDER BY date_created DESC";
$result = mysqli_query($conn, $sql);
show_question($conn, $result);
mysqli_close($conn);
?>
	</div>

</body>
</html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="project.css">
<title>Test show_question</title>
</head>
<body>
<?php 
echo "<h1>Test show_question</h1>";
include "functions.php";
$question = "Vilken blomma föredrar du?";
$image = "flower.jpg";
$alternative = array("ros", "maskros", "fyrklöver");
show_question($question, $alternative, $image);
?>
</body>
</html>