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 > Database display on webpage

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-08-04, 18:33
silvershot silvershot is offline
Registered User
 
Join Date: Oct 2004
Posts: 2
Question Database display on webpage

Hi, I am very new to Sql and databases etc. I just set up my website as php using MySql for the database. Anyways I would like to show data from the data base on a webpage in a table or something, can someone show me how I can do this?
Reply With Quote
  #2 (permalink)  
Old 10-08-04, 18:44
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,410
Google is your friend.
also ISBN 1-59059-150-X
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
  #3 (permalink)  
Old 10-08-04, 18:49
silvershot silvershot is offline
Registered User
 
Join Date: Oct 2004
Posts: 2
I don't know what I am searching for, what I want to do is send data through a program I am creating to the database and then display that new info on a webpage just like a games lobby works.
Reply With Quote
  #4 (permalink)  
Old 10-14-04, 04:00
martynhogg martynhogg is offline
Registered User
 
Join Date: Sep 2004
Posts: 13
Buy a good book on the subject with examples and start practising! I think your question is too vague.
Reply With Quote
  #5 (permalink)  
Old 10-20-04, 20:43
Tylmail.com Tylmail.com is offline
Registered User
 
Join Date: Oct 2004
Location: Manchester, UK.
Posts: 3
Trying to Help a Beginner

Should Help,
Edit Connection Details, Table, Column, Rows and test it!

<?php
// Database Connection Details
define("DB_SERVER","localhost");
define("DB_USER","dbusername");
define("DB_PASS","dbpassword");

// Open Database Connection
$db->connect_host(DB_SERVER, DB_USER, DB_PASS);

// Query the Relevent Table
$str_SQL = "SELECT * FROM tablename";
$result = $db->query_db("databasename",$str_SQL);

// Start to Build the Data Display Table
$pagetext.='<table align="center" cellspacing="1" cellpadding="3" bgcolor="#000000">
<tr>
<td colspan="2" bgcolor="#FFFFFF" align="center">Display Table</td>
</tr>
';

// If More than "0" Results for the Query
// Echo Out a Row for Each Result
if(mysql_num_rows($result)>0)
{
$mydata1=$rows['column1'];
$mydata2=$rows['column2'];
while($rows = mysql_fetch_array($result))
{
$pagetext.=' <tr>
<td bgcolor="#FFFFFF">'.$mydata1.'</td>
<td bgcolor="#FFFFFF">'.$mydata2.'</td>
</tr>
';
}
}
else
// If No Data in the Queried Columns
// Echo Out a Message within the Table
{
$pagetext.=' <tr>
<td colspan="2" bgcolor="#FFFFFF">No Data to Display</td>
</tr>
';
}

// Close the Table
$pagetext.='</table>
';

// Echo Out the Page
echo $pagetext;
?>
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