|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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:
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. |
|
#3
|
|||
|
|||
|
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! |
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > help listing information |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|