General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 9th, 2003, 11:56 AM
jwfc jwfc is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 jwfc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
help listing information

hi. if i have the same type of information in two different queries, say $get800Records and $get1500Records, and i want to list the information as a big table, but have the two information side by side each other. if i were listing just one query it would be something like:

while ($info800 = mysql_fetch_array($get800Records)) {

print "<tr>";
print "<td align=left width=20>";
print $info800[place] . "</td>";

print "<td align=left width=150>";
print $info800[name] . "</td>";

print "<td align=left width=150>";
print $info800[record]. "</td>";

print "<td align=left width=20>";
print $info800[year] . "</td>";

print "</tr>";
}


but i cannot find a way to list the same type of information in a table besides it.

Reply With Quote
  #2  
Old August 10th, 2003, 05:23 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 7
Are there references between the two tables? Show us your table structures, the sql you are using right now and explain what you are expecting to achieve.

Also, you are using mysql_fetch_array() wrong. Either use fetch_assoc or use the flags with fetch_array():
PHP Code:
/*----------------------------------------------
Incorrect
----------------------------------------------*/
mysql_fetch_array$blah )
/*----------------------------------------------
correct
----------------------------------------------*/
mysql_fetch_array$blahMYSQL_ASSOC )
/*----------------------------------------------
or
----------------------------------------------*/
mysql_fetch_array$blahMYSQL_NUM )
/*----------------------------------------------
or, use assoc
----------------------------------------------*/
mysql_fetch_assoc$blah 

There is no need to waste resources as you are doing; wasting resources as you are grabbing two result sets for each record using fetch_array as you are.

One more thing, surround your array indexes with quotes, double or single.
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #3  
Old August 11th, 2003, 01:29 AM
jwfc jwfc is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 jwfc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
actually i made 3 tables. i have been told that my tables were not constructed properly by using different types for the different ids in the tables. can i fix that with an ALTER TABLE command? well in any case, here are the 3 tables I created for my database:

***************************
CREATE TABLE eventsTFTable (

event varchar(20),
eventID int(4) auto_increment,

PRIMARY KEY(eventID)


CREATE TABLE personTFTable (

name varchar(30),
sex varchar(10),
personID int(4) auto_increment,
PRIMARY KEY(personID)


CREATE TABLE recordsTFTable (

record char(10),
year char(6),
place varchar(6),
eventID varchar(4),
personID varchar(4),
recordID int(4) AUTO_INCREMENT,

PRIMARY KEY(recordID)
*********************************


i'm not sure i understand the statement: "you are using mysql_fetch_array() wrong. Either use fetch_assoc or use the flags with fetch_array():"

what i am trying to do with my tables, is to list the top 10 times for a track event, the ppl who ran the respective time, and the year they did it in. i tried spreading out my information using different keys. so i can query this for one single event with:

************************************
SELECT DISTINCT
recordsTFTable.record, recordsTFTable.year, recordsTFTable.place,
eventsTFTable.event,
personTFTable.name, personTFTable.sex
FROM recordsTFTable, personTFTable, eventsTFTable
WHERE personTFTable.personID=recordsTFTable.personID
AND sex LIKE 'female' AND recordsTFTable.eventID=1
LIMIT 10
*************************************

i honestly don't think this is the best way to do it (by using LIMIT 10), but i keep getting replicas of the data otherwise. i am trying to get the information into two side by side tables (or actually one big table, that holds the information for 2 different events). so say men's 800 and women's 800 would be side by side with their respective times, ppl, and yrs, or men's 800 and men's 1500 would be the next table or something along those lines. thanks for the help!

Reply With Quote
  #4  
Old August 15th, 2003, 11:52 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
jwfc,

When you say you get replicas of your data, what do you mean? Can you post a snippet of your output... Also, do you have a live version up on a website anywhere for us to see?

If you mean that you're getting duplicate data showing up, it looks to be your query. You're getting what's called a "Cartesian Product".

Let me know what your output looks like... I'm still a little confused as to the problem you're having.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > help listing information


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT