By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,303 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,303 IT Pros & Developers. It's quick & easy.

Text color in php

P: 93
Hi Again

How do I put a text color in case option? Eg I want the case:ALL the text will be red, case Dialogue the text is yellow, case Montage the text is blue and so on. What is the best way to modify these codes below?

Thnaks

nma

[PHP]
$events = (isset($_REQUEST['events']))?$_REQUEST['events']:"All";
switch($events) {
case "All":
$allEvents = $db->get_results("SELECT * FROM EventsShotsStartAndStopFrames where movieID='$movieID' order by startShot");

foreach($allEvents as $event)
{

$shotStartTime = $event->shotStartFrame/29.97;

if(is_int($event->shotStartFrame)) {
$shotStopTime = $event->shotStopFrame/29.97;
}
else {
$shotStopTime = 0;
}

$numberOfShotsInEvent = $event->endShot - $event->startShot;
$eventInformation = "$event->eventCategory <br />($numberOfShotsInEvent shots)<br />";
$eventInformation .= '<em style="font-size:smaller;">' . sec2hms($shotStartTime) . " - " . sec2hms($shotStopTime).'</em>';
insertEventTableRow($_GET['movieID'], $event->eventID, $event->imgSelectedKeyfrm, $shotStartTime, $shotStopTime, $eventInformation);
}
break;
case "Dialogue":
case "Montage":
case "Exciting":

$db->query("INSERT INTO LogsTable (page, action, userID, type, date) VALUES ('MB2eventlist', '$events categories', " . $_SESSION['user']->userID . ", '', getDate())");

$allEvents = $db->get_results("SELECT * FROM EventsShotsStartAndStopFrames where movieID='$movieID' and eventCategory = '$events' order by eventNo");

foreach($allEvents as $event)
{

$shotStartTime = $event->shotStartFrame/29.97;

if(is_int($event->shotStartFrame)) {
$shotStopTime = $event->shotStopFrame/29.97;
}
else {
$shotStopTime = 0;
}

$numberOfShotsInEvent = $event->endShot - $event->startShot;
$eventInformation = "<b>$events " . $event->eventNo . "</b><br />($numberOfShotsInEvent shots)<br />";
$eventInformation .= '<em style="font-size:smaller;">' . sec2hms($shotStartTime) . " - " . sec2hms($shotStopTime).'</em>';
insertEventTableRow($_GET['movieID'], $event->eventID, $event->imgSelectedKeyfrm, $shotStartTime, $shotStopTime, $eventInformation);
}
break;
default:
die("Invalid Event!");
break;
}

[/PHP]
Feb 7 '08 #1
Share this Question
Share on Google+
8 Replies


MarkoKlacar
Expert 100+
P: 296
Hi,

Are we talking HTML output, or what kind of output are we talking?
Feb 7 '08 #2

nathj
Expert 100+
P: 938
Hi,

I would define the different layout/colour options in a CSS file and then within the case statement output the display using the relvant CSS class/selector or whatever.

Cheers
nathj
Feb 7 '08 #3

P: 93
nma
[PHP]
function insertEventTableRow($movieID, $eventID, $keyFrame, $startTime, $stopTime, $eventInformation) {
?>
<tr bgcolor="#726257" onMouseOver="this.bgColor='#534741';" onMouseOut="this.bgColor='#726257';" style="cursor: pointer;">
<td width="65" valign="top" width="65" height="44" border="1" vspace="2">
<img src="<?php echo $keyFrame;?>"
onclick="parent.playClip(<?php echo $eventID?>, <?php echo $startTime;?>, <?php echo $stopTime;?>);parent.notesForm.eventID.value=<?php echo $eventID?>;parent.resetNotes();">
</td>
<td width="195" class="eventEntryText" onclick="parent.playClip(<?php echo $eventID?>, <?php echo $startTime;?>, <?php echo $stopTime;?>);parent.notesForm.eventID.value=<?php echo $eventID?>;parent.resetNotes();">
<?php echo $eventInformation?>
</td>
</tr>
<tr>
<td colspan="2" height="5">
<img src="iframe-borderline.jpg" width="230" height="5"/>
</td>
</tr>
<?php
}

[/PHP]


I'm so sorry..this is the function to display
thanks

nma
Feb 7 '08 #4

P: 93
nma
[PHP]
<?php echo $Mov1->eventCategory;?>(<?php echo $Mov1->num_events;?>)

[/PHP]

Hi
How do I put the color for this line say green?


Thanks

nma
Feb 12 '08 #5

MarkoKlacar
Expert 100+
P: 296
Hi,

If I understand you correctly, just punt <font>-tags around the php code and it should work fine.
Feb 13 '08 #6

nathj
Expert 100+
P: 938
Hi,

If I understand you correctly, just punt <font>-tags around the php code and it should work fine.
that involves merging content and style - a big pain when it comes to maintaining or changing the site and the behaviour. I would simply define three (or as many as needed) classes in the CSS that only differ interms of colour then you can apply thee depending no the branch of the case statement.

This means that should you need these colours again they are easy to use and should it be that they need to be changed then that is one change in one file - it's waht CSS is for.

Do the smart thing and use CSS for all your style control.

Cheers
nathj

PS I recently had to update a site (written by someone else) that had inline style for everything - it was a pain in the ass to find the content in the code!
Feb 13 '08 #7

P: 93
nma
Thanks for those input...

I manage to put it as css in the <td> attributes..at it works

nma
Feb 13 '08 #8

nathj
Expert 100+
P: 938
Thanks for those input...

I manage to put it as css in the <td> attributes..at it works

nma
Hi nma,

I'm glad you got the desired result and that you managed it with CSS.

All the best with the rest of your project.

nathj
Feb 14 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.