Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Mysql database layout with multiple headings
Old 01-26-2009, 07:27 AM Mysql database layout with multiple headings
Average Talker

Posts: 19
Trades: 0
How do I design a mysql database layout that looks something like this

-------------------------------
|category#1
-------------------------------
|mysql field 1
|mysql field 2
|mysql field 3
-------------------------------
|category#2
-------------------------------
|mysql field 4
|mysql field 5
|mysql field 6
-------------------------------

Right now, my code is just capable of creating a table with category one and the database info under it. I want to be able to enter database information into different categories but don't know the actual PHP code for it.

PHP Code:
 //----- database connection here
        
$sql "SELECT * FROM `weapons` ORDER BY name";
        
$result=mysql_query($sql) or die ('Error: '.mysql_error ());;
        
        
$color="1";
        echo 
'<table id="releases" align="center" cellspacing="0">
        <tr background="/gfx/release_bg.jpg" align="left"><th>Name</th></tr>'
;
        while(
$rows=mysql_fetch_array($result)){
        if(
$color==1){
        echo 
'<tr bgcolor="#2e0015" align="left"><td><img src="/gfx/spacer.png"> <a href="'.$rows["link"].'">'.$rows["name"].'</a></td>';
        
$color="2";
        }
        else {
        echo 
'<tr bgcolor="#1f010f" align=left><td><img src="/gfx/spacer.png"> <a href="'.$rows["link"].'">'.$rows["name"].'</a></td>';
        
$color="1";
        }
        
        }
        echo 
'</table>';
        
mysql_close();
        
?> 
What do I put after else to make another category like "animal" or "food" and then continue with two more echo of <tr>that have like $rows["age"] and $rows["year"]?
rogerchin85 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-26-2009, 09:11 AM Re: Mysql database layout with multiple headings
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
create multiple tables.

animals table:
id
name

data table:
id
animalid
food
age
year
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Mysql database layout with multiple headings
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.97654 seconds with 12 queries