Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 08-06-2005, 03:05 AM   #1
Member (10 bit)
 
Designer's Avatar
 
Join Date: Mar 2004
Location: Essex, UK
Posts: 982
Send a message via AIM to Designer Send a message via MSN to Designer
populating an html table from a mysql database

Hi guys,

I'm cuurently in the process of making a few modifications on my car website which is running on Vbulletin, I'm working on making a 1/4 mile time's chart that show's the username, car make & model (these are extracted from the user's profile -- that bit works). Basically the idea is that the user just enters a time and it add's / updates their entry in a MySQL database i've made, that bit is sort of working.

My main question here is how can i retrieve the entire contents of the database and display it into a table with three columns, the databsae has only one table called "quartermile" and 4 fields "ID" which is the primary key (auto-incremented), "username" varchar field that contains the username they use on the forum, "car" varchar field which combines their make & model of car and finally "qttime" decimal which contains their quarter mile time to 2 decimal places.

I just cant seem to get my head round how to retreieve the entire contents of that database table into an HTML table.

Any advice would be greatly appreciated (already googled this problem for 2 hours with no good info found)


EDIT - I should mention that the site/my scripts are done in php and the output is actually XHTML (i think) as i'm outputting directly into a vbulletin template using variables
Thanks
__________________
Intel Core i7 920 2.66GHz | Asus P6T SE| 6GB Corsair ram | XFX Radeon HD 4780 | 2 x 250 Gb Maxtor SATA II (in RAID 0), 1 x 250GB SATA II | Creative XFI soundcard | Coolermaster 650W PSU | ThermalTake Tsunami case

My new website -Carp Fishing Forums

Last edited by Designer; 08-06-2005 at 03:07 AM.
Designer is offline   Reply With Quote
Old 08-06-2005, 09:06 AM   #2
Member (10 bit)
 
Designer's Avatar
 
Join Date: Mar 2004
Location: Essex, UK
Posts: 982
Send a message via AIM to Designer Send a message via MSN to Designer
don't know if this will be any help to anyone in providing me with an answer but here's the code i've got for the template and for the PHP script.

PHP Code:

<?php 

// ####################### SET PHP ENVIRONMENT ########################### 
error_reporting(E_ALL & ~E_NOTICE); 

// #################### DEFINE IMPORTANT CONSTANTS ####################### 
define('NO_REGISTER_GLOBALS'1); 
define('THIS_SCRIPT''test'); 
// ################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array( 

); 

// get special data templates from the datastore 
$specialtemplates = array( 

); 

// pre-cache templates used by all actions 
$globaltemplates = array( 
'TEST'
); 

// pre-cache templates used by specific actions 
$actiontemplates = array( 

); 

// ######################### REQUIRE BACK-END ############################ 
require_once('./global.php'); 

// ####################################################################### 
// ######################## START MAIN SCRIPT ############################ 
// ####################################################################### 

$navbits = array(); 
$navbits[$parent] = 'Some text here'

<?
$username="usernamegoeshere";     //username for database
$password="passwordgoeshere";     //password for database
$database="dbnamegoeshere"//database name  

mysql_connect("localhost",$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM quartertime";  //Query the Quartertime database table
$result=mysql_query($query);

$i=0;    //reset variable
while ($i $num) {                            //Loop while var is less than DB's total tables

$user=mysql_result($result,$i,"user");        //Get username
$car=mysql_result($result,$i,"car");          //Get users car
$qttime=mysql_result($result,$i,"qmtime");    //Get users Quarter mile time


$i++; //Increment value of variable
}

//Reconnect to Vbulletin database otherwse following just wont work as Vbulletin DB reuired

$database="vbdatabase" ;  //The Vbulletin database name

@mysql_select_db($database) or die( "Unable to select database");
//Lower naviagation bar (original Vbulletin template)
$navbits construct_navbits($navbits); 
eval(
'$navbar = "' fetch_template('navbar') . '";'); 
eval(
'print_output("' fetch_template('TEST') . '");'); 



?>
Here's my current template (which is XHTML i think -- not overly sure)

HTML Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
	<td class="tcat">Quarter mile table :)</td>
</tr>
<tr>
	<td class="alt1">Some text goes here to describe what my quarter mile table is all about</td>
</tr>
</table>
</br>
</br>

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="1" width="100%" align="center">

<tr>
<th><font face="Arial, Helvetica, sans-serif">Username</font></th>
<th><font face="Arial, Helvetica, sans-serif">Car</font></th>
<th><font face="Arial, Helvetica, sans-serif">Quarter-Mile Time</font></th>
</tr>

<if $currentrow !== $lastrow>
<tr>
<td><font face="Arial, Helvetica, sans-serif">$user</font></td>
<td><font face="Arial, Helvetica, sans-serif">$car</font></td>
<td><font face="Arial, Helvetica, sans-serif">$qttime</font></td>

</tr>

</table>
</br>
</br>
Add/Amend my time
<div>
<form action="evaluatetest.php" method="get">
<input type="text" class="bginput" name="quartertime" /></div>
</br>
<input type="submit" class="button" value="Submit / Amend" />
</form>

</br>


$footer
</body>
</html>
hope this will assist someone in helping me out with this as i've been trying to sort this out for nearly a week now and had no luck in finding answers anywhere.

Thanks

Last edited by Designer; 08-06-2005 at 09:08 AM.
Designer is offline   Reply With Quote
Old 08-08-2005, 05:57 AM   #3
Member (10 bit)
 
Designer's Avatar
 
Join Date: Mar 2004
Location: Essex, UK
Posts: 982
Send a message via AIM to Designer Send a message via MSN to Designer
Resolved this, just made new template called $mybits
made repeadted calls to it from the php script
Designer is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:54 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2