/    Sign up×
Community /Pin to ProfileBookmark

table aligning by variables and array….

i hope someone can help me on this i really need someone who can help me solve this problem…its only just a matter of aligning the tables but i really having trouble doing it.

i have a table from a database and here’s its data

[CODE]
ROOM_NO // DAYS // SUBJ_CODE // SECTION_CODE // START // END
603 || M || VSUALS 11 || AR0812 || 07:30 AM || 11:30 AM
603 || MTH || GRPHCS 11 || AR0813 || 11:30 AM || 03:00 PM
603 || MTH || SOC11 || FV0631 || 03:00 PM || 04:30 PM
709 || TH || SCULPT 031|| FV0631 || 07:30 AM || 11:30 PM
709 || M ||LIFPNT 031 || FV0631 || 07:30 AM || 12:30 PM
709 || MTH ||DESIGN 321 || AR24 || 12:30 PM || 04:00 PM
709 || TH ||PRPRAC 241 || AR0541 || 04:30 PM || 07:30 PM
[/CODE]

what i need to do is show them to a table with their corresponding START,END,ROOM_NO and DAYS…
something like this:

[CODE]
ROOM || DAY || 07:30 AM – 09:00 AM || 09:00 AM – 10:30 || and so on..
709 || M || LIFPNT 031 / FV0631 //this will continue until 12:30 PM
|| TH || SCULPT 031 / FV0631 //and the time table is fixed to 1
//1/2 interval
[/CODE]

i tried writing a code and here it is…

[CODE]
<?
$GetResult =mysql_query(“SELECT * FROM tblSched”);
?>
<table>
<tr>
<th>Room No</th>
<th>Days</th>
<th>07:30 – 09:00 AM</th>
<th>09:00 – 10:30 AM</th>
<th>Room No</th>
</tr>
<?
while ($row = mysql_fetch_array($GetResult)) {
?>
<tr>
<td><? echo $row[‘ROOM_NO’];?></td>
///// My problem here is
//that it show 3 difference results and i
//don’t know how to not show the
//duplicates, i tried using array_unique but
//it still did not work…

<td><? echo $row[‘DAYS’];?></td>
// also with this the days are all scrambled up
// and it messes all the tables…

$row[‘SUBJ_CODE’];
$row[‘SECTION_CODE’];
$row[‘START’];
$row[‘END’];
}
?>
</table>
[/CODE]

i think i have to make an array to solve this problem…but i dont know where to start,i hope someone can help me on this or give me an example..tnx

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@DragonkaiJul 22.2008 — What in a nut shell are you trying to do...?

Show us the format you want it in.. like as in an actual webpage format, not just
[CODE]
ROOM || DAY || 07:30 AM - 09:00 AM || 09:00 AM - 10:30 || and so on..
709 || M || LIFPNT 031 / FV0631 //this will continue until 12:30 PM
|| TH || SCULPT 031 / FV0631 //and the time table is fixed to 1

//1/2 interval
[/CODE]
Copy linkTweet thisAlerts:
@nebchill26authorJul 22.2008 — sorry about that here's a an html page of what it should look like...

[CODE]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<table border="1" cellpadding="1" cellspacing="1" align="center" width="900">
<tr>
<th>Room</th>
<th>Day</th>
<th>07:30 - 09:00 AM</th>
<th>09:00 - 10:30 AM</th>
<th>10:30 - 12:00 PM</th>
<th>12:00 - 01:30 PM</th>
<th>01:30 - 03:00 PM</th>
<th>03:00 - 04:30 PM</th>
<th>04:30 - 06:00 PM</th>
<th>06:00 - 07:30 PM</th>
<th>07:30 - 09:00 PM</th>
</tr>

<tr>
<td rowspan="2">603</td>
<td>M</td>
<td>
VSUALS 11
AR0812
</td>
<td>
VSUALS 11
AR0812
</td>
<td>
VSUALS 11
AR0812 11:30 AM
</td>
<td>
11:30 AM
GRPHCS 11
AR0813
</td>
<td>
GRPHCS 11
AR0813
</td>
<td>
SOC11
FV0631

</td>
</tr>
<tr>
<td>TH</td>
<td>
&nbsp;
</td>
<td>
&nbsp;
</td>
<td>
&nbsp;
</td>
<td>
11:30 AM
GRPHCS 11
AR0813
</td>
<td>
GRPHCS 11
AR0813
</td>
<td>
SOC11
FV0631
</td>
</tr>
</table>
</body>
</html>
[/CODE]
Copy linkTweet thisAlerts:
@DragonkaiJul 23.2008 — Ok, I see a problem in the rowspan of 603.. will it always be 2?

You'll need to count the amount of 603 entries and increase the number accordingly.

Apparently I see what you need to do, is to match all which are 603s or whatever other number and this number would first be displayed in the html of rowspan of 603. mysql_num_rows can help in that.

Your problem with multiple 603s coming up due to multiple records. Can be solved by separating table into a key table with satellite tables which include the actual data for each day. If you don't want to do that, you can use the DISTINCT in your query. Search up on resources for how to do that.
Copy linkTweet thisAlerts:
@nebchill26authorJul 23.2008 — thank you for replying...yes thats exactly my problem...

the rowspan depends on the days of the table,do you have any examples that i can use as a reference by satellite tables?
Copy linkTweet thisAlerts:
@DragonkaiJul 23.2008 — If you want to do that, look up on "Foreign Key" in mysql. Or "One to many relationships" or "relational database mysql" in google, I don't have quite alot of time to actually give you an example, but that should get you started.
×

Success!

Help @nebchill26 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...