If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Show Values on HTML

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-06-08, 09:50
THE DON THE DON is offline
Registered User
 
Join Date: May 2007
Posts: 8
Show Values on HTML

I have a vbulletin forum. What I need is, that last value from table "userid" shows on a HTML page using "include php"

Actually I want to show the number of users on the main page of my website, which in HTML format. But that should be in the form of "2,000" if the last value is 2000

Is it possible?

Right now I am using this PHP to extract the value and then using include tags in HTML page to fetch this file

PHP Code:
<?php
$con 
mysql_connect("localhost","username","pass");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("database"$con);

$result mysql_query("SELECT userid FROM user ORDER BY userid DESC LIMIT 0,1");

echo 
"<table border='0'>";
echo 
"<tr>";
while(
$row mysql_fetch_array($result))
  {
  echo 
"<td style='color:#FF0000 '>" $row['userid'] . "</td>";
  } 
    {
  echo 
"<td>Users Online & counting. Are you one of them?</td>";
  }
  {
  echo 
"</tr>";
  }
echo 
"</table>";

mysql_close($con);
?>
Reply With Quote
  #2 (permalink)  
Old 12-06-08, 10:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
SELECT COUNT(*) AS number_of_users
FROM user
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-06-08, 12:18
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Actually I want to show the number of users on the main page of my website, which in HTML format. But that should be in the form of "2,000" if the last value is 2000
you could use the PHP function number_format to add the comma's.

echo number_format( $num_users );
Reply With Quote
  #4 (permalink)  
Old 12-06-08, 13:14
THE DON THE DON is offline
Registered User
 
Join Date: May 2007
Posts: 8
How can I use that? I dont know PHP or MYSQL, so please explain me. The file I am using has been coded by someone else and I found it over internet. Please explain that to me.
Reply With Quote
  #5 (permalink)  
Old 12-06-08, 13:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by THE DON
I dont know PHP or MYSQL
with all respect, if you don't know php or mysql, maybe you should get someone else to do this for you
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 12-06-08, 13:22
THE DON THE DON is offline
Registered User
 
Join Date: May 2007
Posts: 8
OK, anyone here can do that? How much I have to pay?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On