Please excuse my terminology as its a little shocking, I know. Currently I'm reading data from a MySQL database which is loaded into text and 4 buttons which are displayed on the webpage. This is used for a simple RPG system loading the data from a MySQL database and then loading the corresponding scenario based on the choices made by clicking on the buttons. Then using the data from the PHP loads the corresponding webpage using data in the parameters so for example:
I want it to load example.com/index.php?id=1&story=2 however for some unknown reason I cannot get the code to do that and every time it loads example.com/index.php (without the extra parameters which I need). Here is the code:
<?php
//Get the parameters
$id = $_GET["id"];
$story = $_GET["story"];
// Connect to the MySQL
$con=mysqli_connect("HOST_HERE","USER_HERE","PASSWORD_HERE","DATABASE_HERE");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM Story");
while($row = mysqli_fetch_array($result))
{
if ($id == $row['GameID'])
{
if ($story == $row['StoryID'])
{
echo "<center>" . $row['Scenario'] . "</center>";
echo "<br><form method='link1' action='index.php?id=" . $id . "&story=" . $row['ChoiceAID'] . "'>";
echo "<input type='submit' value='" . $row['ChoiceA'] . "'></form>";
echo "<br><form method='link2' action='index.php?id=" . $id . "&story=" . $row['ChoiceBID'] . "'>";
echo "<input type='submit' value='" . $row['ChoiceB'] . "'></form>";
echo "<br><form method='link3' action='index.php?id=" . $id . "&story=" . $row['ChoiceCID'] . "'>";
echo "<input type='submit' value='" . $row['ChoiceC'] . "'></form>";
echo "<br><form method='link4' action='index.php?id=" . $id . "&story=" . $row['ChoiceDID'] . "'>";
echo "<input type='submit' value='" . $row['ChoiceD'] . "'></form>";
}
}
}
mysqli_close($con);
?>
The live site to help explain whats wrong is here: http://www.textbasedrpg.site90.com/?id=1&story=1
while($row = mysqli_fetch_array($result))addprint_r($row);to check exact field names