allensim81 Posted July 17, 2009 Share Posted July 17, 2009 Hi, i checked my code and trying my best to improve it. But wonder why, the data that key in by user is still not showing... I had created mysql db and table... but wonder y data key in by user stl wont be able to insert into db and shown out in the browser.... Can you please guide me? Thanks in advance <html> <?php $database="websites_database"; $user = 'root'; $password = ''; mysql_connect("localhost",$user,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO websitestable VALUES ('$websites','$destination')"; $query="SELECT * FROM websitestable"; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) { $websites=mysql_result($result,$i,"websites"); $destination=mysql_result($result,$i,"destination"); $i++; } ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Websites</font></th> <th><font face="Arial, Helvetica, sans-serif">Destination</font></th> </tr> <? $i=0; while ($i < $num) { $websites=mysql_result($result,$i,"websites"); $destination=mysql_result($result,$i,"destination"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><? echo $websites; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><? echo $destination; ?></font></td> </tr> <? $i++; } echo "</table>"; ?> <body> <h1>Goverment Websites</h1> <form action="insert.php" method="post"> <p>Website address:</p> http:// <input type="text" name="websites" size="60"> destination: <input type="text" name="destination" size="30"> <input type="submit" value="Submit"> </form> </html> Link to comment https://forums.phpfreaks.com/topic/166282-data-key-in-by-user-not-shown/ Share on other sites More sharing options...
o3d Posted July 17, 2009 Share Posted July 17, 2009 $query = "INSERT INTO websitestable VALUES ('$websites','$destination')"; $query="SELECT * FROM websitestable"; you'll have to execute the insert statement before you can select the data Link to comment https://forums.phpfreaks.com/topic/166282-data-key-in-by-user-not-shown/#findComment-876882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.