A2xA Posted January 25, 2008 Share Posted January 25, 2008 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! Quote Link to comment Share on other sites More sharing options...
A2xA Posted January 25, 2008 Author Share Posted January 25, 2008 not echo I guess it's a print... Quote Link to comment Share on other sites More sharing options...
revraz Posted January 25, 2008 Share Posted January 25, 2008 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. Quote Link to comment Share on other sites More sharing options...
A2xA Posted January 26, 2008 Author Share Posted January 26, 2008 well, I want it to echo for everyone to view. Like if you go there you could see it there? And where many people could insert it and it would show like 10 of them. Thanks! Quote Link to comment Share on other sites More sharing options...
A2xA Posted January 26, 2008 Author Share Posted January 26, 2008 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>"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.