Thanks for reading my question.
I am trying to create a website where information from a database is displayed on a web page. The end result is as follows , but for a different game.
Here is a simple HTML page that I want it to look like.
So far, I know that my database connection is working. When I run:
mysql_select_db("DATABASE", $con);
$result = mysql_query("SELECT * FROM DATABASE");
while($row = mysql_fetch_array($result)) {
echo $row['Title'] . " " . $row['Type'];
echo "<br />";
}
It returns Title and Type.
What I want to do is run the If / Else statement, which runs a different block of code depending on the type of card.
while($row = mysql_fetch_array($result)) {
if ($row['Title'] == 'Hero') {
echo "<div>";
}
}
I tried this based on the lessons at w3schools.com, but this does not work.
Do you have any ideas on what I should do?
EDIT:
Here is what I tried to run:
while($row = mysql_fetch_assoc($result)) {
if ($row['Title'] == 'Hero') {
echo $row['Title'] . " Hero.<br>";
} else {
echo $row['Title'] . " Who cares.<br>";
}
}
Here is the result (Gimli should appear as a Hero):
For Gondor! Who cares.<br>
Bilbo Baggins Who cares.<br>
Ungoliant Spwan Who cares.<br>
Gimli Who cares.
2: , , , , . .