Jump to content

how to echo mysql entry?


A2xA

Recommended Posts

I have made a code that makes mysql entries and need it to echo into a table.  Here's my code:

 

<?php
$db_host = "blurred out";
$db_user = "blurred out";
$db_pwd = "blurred out";
$db_name = "blurred out";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
?>
<html>
<head>
<title>WiiCharged Game Hubs</title>
</head>
<body>
<?php
if (!isset($_POST['submit'])) {
?>
<form action="" method="post">
Game <input type="text" name="game"><br>
Friend Code <input type="text" name="fc"><br>
<input type="submit" name="submit" value="Submit!">
</form>
<?php
} else {
$name = $_POST[‘game’];
$color = $_POST[‘fc’];
mysql_query("INSERT INTO `hubs` (game, friend_code) VALUES ('$game', ‘$fc’)");
echo "Success! Your game hub has been added!";
}
?>
</body>
</html>

 

How afterwards would I echo into a table underneath?  My place I'm trying to get it to work is here: http://wiicharged.com/index.php?action=hubs

 

 

Thanks, all help is greatly appreciated and thanked!  I'm glad I have this place, I don't know what I would do without it!  ;)

 

Link to comment
https://forums.phpfreaks.com/topic/87842-how-to-echo-mysql-entry/
Share on other sites

echo, print.. same thing.

 

mysql_query("INSERT INTO `hubs` (game, friend_code) VALUES ('$game', ‘$fc’)");

echo "Success! Your game hub has been added!";

echo $game."<br />";

echo $fc."<br />";

 

And your Success message will not always be accurate, since you don't check if it was a success.

something like this?

 

<?php
// Connects to your Database
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());
$data = mysql_query("SELECT * FROM hubs")
or die(mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th>game:</th> <td>".$info['game'] . "</td> ";
Print "<th>fc:</th> <td>".$info['friend_codes'] . " </td></tr>";
}
Print "</table>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.