Hi everyone, I'm studying ICT in Belgium and we have the task to design a website.
So I'm working on a website for like parties, events and stuff.
So I wrote the following code :
<?php
$link = mysqli_connect("localhost","root","","partyguide")
or die ('Er ging iets mis: ' . mysqli_connect_error($link));
$sql = "SELECT * FROM evenementen";
if(!empty($_POST))
{
$sql.="WHERE id='" .$_POST["evenement_datum"]."'";
}
$result = mysqli_query($link,$sql);
?>
<html>
<head>
<title>Evenementen</title>
</head>
<body>
<?php
if(empty($_POST))
{
$link = mysqli_connect("localhost","root","","partyguide")
or die ('Er ging iets mis: ' . mysqli_connect_error($link));
?>
<form name="form1" action="<?php echo($_SERVER["PHP_SELF"]);?>" method="post">
Kies een datum : <select name="evenement_datum">
<?php
while($rij = mysqli_fetch_array($result)){
echo("<option value=\"".$rij['datum']."\">".$rij['datum']."</option>\n");
}?>
</select>
<input type="Submit" value="Toon evenementen!">
</form>
<?php
}else{
?>
<table width="1000" height="500" align="center" border="1" bordercolor="blue">
<?php
while($rij = mysqli_fetch_array($result)){
?>
<tr>
<td><?php echo $rij['datum']; ?></td>
<td><?php echo $rij['plaats']; ?></td>
<td><?php echo $rij['tijdstip']; ?></td>
<td><?php echo $rij['naam'] ?></td>
</tr>
<?php
} ?> </table>
<?php
}
?>
</body>
</html>
So I'm trying to have an option box which displays the date's of events in my database, If i click a date, it has to display all the events in a table, but whenever I click one, following error pops up :
Catchable fatal error: Object of class mysqli_result could not be converted to string in D:\www\evenementen.php on line 11
Can anyone help me with this? My teacher doesn't know how to solve this so I hope anyone of you could...