McChicken Posted October 8, 2008 Share Posted October 8, 2008 Hey. I want to generate my database in a table on a php/html page. something like this: Can someone help me with the code? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/127576-solved-generate-db-data-in-a-page/ Share on other sites More sharing options...
php.ajax.coder Posted October 8, 2008 Share Posted October 8, 2008 Try looking at this http://www.w3schools.com/php/php_mysql_create.asp Quote Link to comment https://forums.phpfreaks.com/topic/127576-solved-generate-db-data-in-a-page/#findComment-660082 Share on other sites More sharing options...
Chicken Little Posted October 8, 2008 Share Posted October 8, 2008 Try this and modify where needed <?php $username = "yourusername"; $password = "yourpassword"; $hostname = "yourhostname"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("yourdatabasename",$dbh) or die("Could not get database"); $result = mysql_query("SELECT * FROM ip_hits ORDER BY clicks, date DESC LIMIT 0,10"); //while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo "<table cellspacing='15'>"; echo "<tr><td colspan='3'><hr /></td></tr>"; while($row = mysql_fetch_assoc($result)) { extract ($row); echo "<tr>\n <td>$id</td>\n <td>$clicks</td>\n <td>$ip</td>\n <td>$BrukerID</td>\n <td>$date</td>\n </tr>\n"; echo "<tr><td colspan='3'><hr /></td></tr>\n"; } echo "</table>\n"; Quote Link to comment https://forums.phpfreaks.com/topic/127576-solved-generate-db-data-in-a-page/#findComment-660233 Share on other sites More sharing options...
McChicken Posted October 9, 2008 Author Share Posted October 9, 2008 Thank you little chicken. I'm not 100% happy with the results, but it's a good start:) Quote Link to comment https://forums.phpfreaks.com/topic/127576-solved-generate-db-data-in-a-page/#findComment-661100 Share on other sites More sharing options...
McChicken Posted October 9, 2008 Author Share Posted October 9, 2008 A little change here fixed it:) Thank you again Little chicken! $result = mysql_query("SELECT * FROM `ip_hits` ORDER BY `ip_hits`.`date` DESC LIMIT 0, 30 ; "); Quote Link to comment https://forums.phpfreaks.com/topic/127576-solved-generate-db-data-in-a-page/#findComment-661117 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.