Text color in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nma
    New Member
    • Aug 2007
    • 93

    Text color in php

    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($_REQUES T['events']))?$_REQUEST['events']:"All";
    switch($events) {
    case "All":
    $allEvents = $db->get_results("S ELECT * FROM EventsShotsStar tAndStopFrames where movieID='$movie ID' order by startShot");

    foreach($allEve nts as $event)
    {

    $shotStartTime = $event->shotStartFra me/29.97;

    if(is_int($even t->shotStartFrame )) {
    $shotStopTime = $event->shotStopFram e/29.97;
    }
    else {
    $shotStopTime = 0;
    }

    $numberOfShotsI nEvent = $event->endShot - $event->startShot;
    $eventInformati on = "$event->eventCategor y <br />($numberOfShot sInEvent shots)<br />";
    $eventInformati on .= '<em style="font-size:smaller;"> ' . sec2hms($shotSt artTime) . " - " . sec2hms($shotSt opTime).'</em>';
    insertEventTabl eRow($_GET['movieID'], $event->eventID, $event->imgSelectedKey frm, $shotStartTime, $shotStopTime, $eventInformati on);
    }
    break;
    case "Dialogue":
    case "Montage":
    case "Exciting":

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

    $allEvents = $db->get_results("S ELECT * FROM EventsShotsStar tAndStopFrames where movieID='$movie ID' and eventCategory = '$events' order by eventNo");

    foreach($allEve nts as $event)
    {

    $shotStartTime = $event->shotStartFra me/29.97;

    if(is_int($even t->shotStartFrame )) {
    $shotStopTime = $event->shotStopFram e/29.97;
    }
    else {
    $shotStopTime = 0;
    }

    $numberOfShotsI nEvent = $event->endShot - $event->startShot;
    $eventInformati on = "<b>$events " . $event->eventNo . "</b><br />($numberOfShot sInEvent shots)<br />";
    $eventInformati on .= '<em style="font-size:smaller;"> ' . sec2hms($shotSt artTime) . " - " . sec2hms($shotSt opTime).'</em>';
    insertEventTabl eRow($_GET['movieID'], $event->eventID, $event->imgSelectedKey frm, $shotStartTime, $shotStopTime, $eventInformati on);
    }
    break;
    default:
    die("Invalid Event!");
    break;
    }

    [/PHP]
  • MarkoKlacar
    Recognized Expert Contributor
    • Aug 2007
    • 296

    #2
    Hi,

    Are we talking HTML output, or what kind of output are we talking?

    Comment

    • nathj
      Recognized Expert Contributor
      • May 2007
      • 937

      #3
      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

      Comment

      • nma
        New Member
        • Aug 2007
        • 93

        #4
        [PHP]
        function insertEventTabl eRow($movieID, $eventID, $keyFrame, $startTime, $stopTime, $eventInformati on) {
        ?>
        <tr bgcolor="#72625 7" onMouseOver="th is.bgColor='#53 4741';" onMouseOut="thi s.bgColor='#726 257';" 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;?>);p arent.notesForm .eventID.value= <?php echo $eventID?>;pare nt.resetNotes() ;">
        </td>
        <td width="195" class="eventEnt ryText" onclick="parent .playClip(<?php echo $eventID?>, <?php echo $startTime;?>, <?php echo $stopTime;?>);p arent.notesForm .eventID.value= <?php echo $eventID?>;pare nt.resetNotes() ;">
        <?php echo $eventInformati on?>
        </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

        Comment

        • nma
          New Member
          • Aug 2007
          • 93

          #5
          [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

          Comment

          • MarkoKlacar
            Recognized Expert Contributor
            • Aug 2007
            • 296

            #6
            Hi,

            If I understand you correctly, just punt <font>-tags around the php code and it should work fine.

            Comment

            • nathj
              Recognized Expert Contributor
              • May 2007
              • 937

              #7
              Originally posted by MarkoKlacar
              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!

              Comment

              • nma
                New Member
                • Aug 2007
                • 93

                #8
                Thanks for those input...

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

                nma

                Comment

                • nathj
                  Recognized Expert Contributor
                  • May 2007
                  • 937

                  #9
                  Originally posted by nma
                  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

                  Comment

                  Working...