horstefan Posted February 9, 2012 Share Posted February 9, 2012 Hello, I know i'm new, i hope it wont stop you guys from putting 5 minutes of your time to help me out. I need a script to get some data from mysql and put this into a table. i have a mysql database called "denora" In there is a table called "chan" In table chan are the columns: chanid (unique number), channel, currentusers, mode_ls I would like the script to make a html table that lists the top10 channels (most "currentusers" on top) And when "mode_ls" is "Y" it must not be shown (secret channel) My knowledge of php and mysql arent that great so i really hope someone takes the time to help me uit Kind regards Stefan Quote Link to comment https://forums.phpfreaks.com/topic/256776-req-script-to-get-some-data-from-mysql-and-put-it-into-a-table/ Share on other sites More sharing options...
litebearer Posted February 10, 2012 Share Posted February 10, 2012 What have you tried so far, and what errors did you get? Quote Link to comment https://forums.phpfreaks.com/topic/256776-req-script-to-get-some-data-from-mysql-and-put-it-into-a-table/#findComment-1316380 Share on other sites More sharing options...
Stavros Posted February 10, 2012 Share Posted February 10, 2012 W3 schools is a good resource http://www.w3schools.com/php/php_mysql_select.asp Quote Link to comment https://forums.phpfreaks.com/topic/256776-req-script-to-get-some-data-from-mysql-and-put-it-into-a-table/#findComment-1316433 Share on other sites More sharing options...
delickate Posted February 10, 2012 Share Posted February 10, 2012 Hi, You can do like this: echo "<table>"; echo "<tr><td><b>FieldOne</b></td> <td><b>FieldTwo</b></td></tr>"; $qry = mysql_query("select * from tableName"); while($rec = mysql_fetch_assoc($qry)) { echo "<tr><td>".$rec['fieldone']."</td> <td>".$rec['fieldTwo']."</td></tr>"; } echo "<table>"; Hope it'll help you Quote Link to comment https://forums.phpfreaks.com/topic/256776-req-script-to-get-some-data-from-mysql-and-put-it-into-a-table/#findComment-1316450 Share on other sites More sharing options...
kirankumer Posted February 10, 2012 Share Posted February 10, 2012 <?php // your database connection settings.. $conn=mysql_connect("localhost","root"," "); echo "<table>"; echo "<tr><td><b>channelid</b></td> <td><b>channel</b></td> <td><b>current users</b></td></tr>"; $qry="select chanid, channel, currentusers from denora.chan where mode_ls =Y order by chanid desc limit 0 ,10 "; $data =mysql_query($qry); while($row=mysql_fetch_assoc($data)) { echo "<tr><td>".$rec['channelid']."</td> <td>".$rec['channel']."</td> <td>".$rec['currentusers']."</td></tr>"; } echo </table>; ?> Quote Link to comment https://forums.phpfreaks.com/topic/256776-req-script-to-get-some-data-from-mysql-and-put-it-into-a-table/#findComment-1316459 Share on other sites More sharing options...
horstefan Posted February 11, 2012 Author Share Posted February 11, 2012 kirankumer thanks soo many times! i made a little tweaks, but this is exacly what i was looking for! a little sidenote to your code: echo </table>; must be echo "</table>"; and $rec must be $row it works great! Quote Link to comment https://forums.phpfreaks.com/topic/256776-req-script-to-get-some-data-from-mysql-and-put-it-into-a-table/#findComment-1316867 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.