Jump to content

REQ: script to get some data from mysql and put it into a table


horstefan

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

<?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>;

 

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.