Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Databasing
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-08-2009, 08:32 AM
  #1
wedmonds
Aspirant (Level 2)
 
Join Date: Aug 2009
Posts: 14
iTrader: (0)
wedmonds is an unknown quantity at this point
Displaying data from Database

Hi All,

I not sure of the name of the function that I am after so hoping someone can advise.

I would like to setup 5 columns on my webpage.
I would then like to have a database sitting in the background.

When a change is made to the database, I would like it to automatically adjust my web page with the data. Ideally keeping to a standard layout, colour, font etc.

Anyone know the name of what I am trying to describe

Many Thanks

wedmonds is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-08-2009, 10:14 AM
  #2
cmetz1977
Myrmidon (Level 12)
 
cmetz1977's Avatar
 
Join Date: May 2008
Location: Lakeland, FL
Posts: 193
iTrader: (0)
cmetz1977 will become famous soon enough
What is your background? Do you know databasing but not website layout? Vice-versa?

This answer can get pretty involved, letting us know your expertises will help you get a more direct answer. Also, what are you using: PHP/MySQL? ASP/MSSQL? something else?
__________________
Never accept Kool-aid from someone who won't drink from the same punch bowl.
cmetz1977 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-09-2009, 04:00 AM
  #3
wedmonds
Aspirant (Level 2)
 
Join Date: Aug 2009
Posts: 14
iTrader: (0)
wedmonds is an unknown quantity at this point
Very limited knowledge so I was planning to learn it from the ground up.
I have worked in support for some years though so I normally get my head around things eventually.

Database will be mysql using cpanel or navicat

The database will not get huge but the idea is to let other people enter data into a table and then it automatically update the website.

Exact help would be really appreciated although some key areas for me to look at would be of equal help

Hope that makes sense (only on my first coffee)

wedmonds is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-09-2009, 09:30 AM
  #4
cmetz1977
Myrmidon (Level 12)
 
cmetz1977's Avatar
 
Join Date: May 2008
Location: Lakeland, FL
Posts: 193
iTrader: (0)
cmetz1977 will become famous soon enough
I'll be vague and you tell me where you need more info.

Initial query
PHP Code:
$connection mysql_connect'server''username''password' )
   or die( 
mysql_error( ) );
$connection mysql_select_db'database'$connection )
   or die( 
mysql_error( ) );

$query mysql_query"SELECT * FROM logs WHERE date = '2009-08-23'"$connection )
   or die( 
mysql_error( ) ); 
I've add "or die( mysql_error( ) )" to all these above to help you troubleshoot any connection or query issues.

The first 2 lines of code connect to your server (this value is generally 'localhost') using your username and password (don't literally use 'username' and 'password') which you've configured when you set up mysql. Then, since your server can usually host multiple databases, you need to replace 'database' with the name of the database you wish to access.

The 3rd line of code returns every column from each value that is date stamped as occuring on August 23, 2009.

Displaying the results
PHP Code:
if( $query && mysql_num_rows$query ) )
{
   print( 
"<table>\n" );
   while( 
$result mysql_fetch_assoc$query ) )
      print( 
"   <tr>   <td>{$result[ 'name' ]}</td>   <td>{$result[ 'userid' ]}</td>   </tr>\n" );
   print( 
"</table>\n" );

This portion only occurs if the query's syntax was correct and produced results. If both these conditions are met, the opening tag of a table is printed, then each result from the query as a row, then the closing tag of the table. Using a table here assures your data will structured as you were initially concerned.

The WHILE statement iterates through each row of the result in the order it was returned and stores it in an associative array named $result. From there, each column can be referenced by its field name in your database; this sample assumes you have fields 'name' and 'userid' in your table named 'logs'.


This can get infinitely more complex as you customize this. For example, ordering results in the query or using user criteria in your query (which you MUST clean first).

Godspeed!
__________________
Never accept Kool-aid from someone who won't drink from the same punch bowl.
cmetz1977 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-15-2009, 12:07 PM
  #5
wedmonds
Aspirant (Level 2)
 
Join Date: Aug 2009
Posts: 14
iTrader: (0)
wedmonds is an unknown quantity at this point
Thanks for reply and sorry its taken a while to come back to this.

I will have a go and see how I get on. What is this process called? I would like to look for other articles on the interweb.

wedmonds is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 04:36 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.