Loading ...
Sorry, an error occurred while loading the content.

Re: [phpXperts] Text Color in PHP

Expand Messages
  • Anjan Bhowmik
    I think the problem is in here $row[ $thesis ] which should be $row[ thesis ] that is without the $ sign inside the This should solve ur problem. Since you
    Message 1 of 10 , Jul 30, 2010
    • 0 Attachment
      I think the problem is in here $row['$thesis'] which should be $row['thesis'] that is without the $ sign inside the ''

      This should solve ur problem.

      Since you are using single quotes $row['$thesis'] means a key named "$thesis" in array $row, where in reality u want the key 'thesis' in array $row. So, be on guard where u put the $ signs :) or u will be out of ur mind for a while :D

      Thanks,
      Anjan

      On Fri, Jul 30, 2010 at 6:56 AM, Mety Soriano <metysoriano@...> wrote:
       

      sir it does not work, this is my codes
       
      $color1 = "#EEEEEE";
       $color2 = "#EEEEEE";
       $row_count = 0;
           $search_text = thesis;
         
       
        
        
           $highlighted_text = '<span class="highlight">'.$search_text.'</span>';
           
       
                          while ($row = mysql_fetch_array($booktitle)) {
           
           
             
            $row_color = ($row_count % 2) ? $color1 : $color2;
            
             $row['$thesis'] = str_ireplace($search_text, $highlighted_text,$row['thesis']);

           
            if ($row['status'] == 'BORROWED')
            {
            $row_color = "#CCCCCCC";
            
            }
            
            else
            {
            echo "</tr>";
            }
                
                             
                           
                           ?> 
                            <tr>
         
      <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['barcode'];?></font></div></td>
      <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['code'];?></font></div></td>
      <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2">
      <img src="thesis_icon.png" align="absmiddle" />&nbsp;&nbsp;<?php echo "<a href ='thesis_open.php?thesis_opener=".$row['thesis_recno']."'>";?><?php echo $row['title'];?></a></font></div></td>   
         
      <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace"size="2"><?php echo $row['author'];?></font></div></td>
      <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['cright'];?></font></div></td>
      <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['course'];?></font></div></td>
           
           
      <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['status'];?></font></div></td>
                           
           <?php
            
       
       
                           $row_count++;
          }
        

      MATIAS 'Mety' SORIANO
      MIS/IT Administrator/Consultant/Professor
      Contacts: Tel: (042)3736167 Cel: 09282860545
       


      --- On Thu, 29/7/10, Anjan Bhowmik <anjan011@...> wrote:

      From: Anjan Bhowmik <anjan011@...>
      Subject: Re: [phpXperts] Text Color in PHP
      To: phpexperts@yahoogroups.com
      Date: Thursday, 29 July, 2010, 12:32 PM

       
      When u get the row from result set u can aplly string replace ....

      $search_text = 'PHP';

      $highlighted_ text = '<span class="highlight">'.$search_text.'</span>'; // using the highlight css class u can do the text highlighting

      while($row = mysql_fetch_ row($result) )
      {
         // assuming the 'text' field contains book name, or description ...
        
         $row['text'] = str_ireplace( $search_text, $highlighted_ text,$row['text']);
      }

      // resume with rest of the code processing ....

      Hope this helps :)

      On Thu, Jul 29, 2010 at 8:31 AM, Mety <metysoriano@ yahoo.com> wrote:
       
      I want to highlight the word that I type in a text box. Example I would like to search the book that contains 'PHP', then all book that contains PHP will display BUT the the word PHP will BOLD or have different in color.

      Below is my code in quey a book

      $color1 = "#EEEEEE";
      $color2 = "#EEEEEE";
      $row_count = 0;






      while ($row = mysql_fetch_ array($booktitle )) {


      $row_color = ($row_count % 2) ? $color1 : $color2;



      if ($row['status'] == 'BORROWED')
      {
      $row_color = "#CCCCCCC";

      }

      else
      {
      echo "</tr>";
      }
      ?>



      <tr>

      <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['barcode'];?></font></div></td>
      <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['code'];?></font></div></td>
      <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2">
      <img src="thesis_icon. png" align="absmiddle" />&nbsp;&nbsp;<?php echo "<a href ='thesis_open. php?thesis_ opener=".$row['thesis_recno']."'>";?><?php echo $row['title'];?></a></font></div></td>

      <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace"size="2"><?php echo $row['author'];?></font></div></td>
      <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['cright'];?></font></div></td>

      <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['course'];?></font></div></td>


      <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['status'];?></font></div></td>

      Please help me.

      Thank you




      --
      Anjan Bhowmik
      Software & Web Development Department
      Ultra Soft
      Mobile : +8801670556419, +8801673636742
      Email : anjan011@gmail. com,info@ultrasoftbd. com




      --
      Anjan Bhowmik
      Software & Web Development Department
      Ultra Soft
      Mobile : +8801670556419,+8801673636742
      Email : anjan011@...,info@...
    • Praveena Sarathchandra
      Message 2 of 10 , Jul 30, 2010
      • 0 Attachment
        <?php

        $color1 = "#EEEEEE";
        $color2 = "#CCCCCC";
        $row_count = 0;  
        $search_text = "thesis";
            
         
           
           
             $highlighted_text = '<span class="highlight">'.$search_text.'</span>';
             
          
                            while ($row = mysql_fetch_array($booktitle)) {
             
             
                
              $row_color = ($row_count % 2) ? $color1 : $color2;
              
               $row['$thesis'] = str_ireplace($search_text, $highlighted_text,$row['thesis']);

             
              if ($row['status'] == 'BORROWED')
              {
              $row_color = "#CCCCCCC";
              
              }
              
              else
              {
              echo "</tr>";
              }
                  
                                
                              
                             ?> 
                              <tr>
            
        <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['barcode'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['code'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2">
        <img src="thesis_icon.png" align="absmiddle" />&nbsp;&nbsp;<?php echo "<a href ='thesis_open.php?thesis_opener=".$row['thesis_recno']."'>";?><?php echo $row['title'];?></a></font></div></td>    
            
        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace"size="2"><?php echo $row['author'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['cright'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['course'];?></font></div></td>
             
             
        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['status'];?></font></div></td>
                             
             <?php
              
          
         
                             $row_count++;
            }

        Best Regards,

          Praveena J. Sarathchandra
          Freelance Web Designer/Developer

          [@] praveenaj@...
          [M] +94-77-6275266
          [W] www.myBiz.lk


        On Fri, Jul 30, 2010 at 6:26 AM, Mety Soriano <metysoriano@...> wrote:
         

        sir it does not work, this is my codes
         
        $color1 = "#EEEEEE";
         $color2 = "#EEEEEE";
         $row_count = 0;
             $search_text = thesis;
           
         
          
          
             $highlighted_text = '<span class="highlight">'.$search_text.'</span>';
             
         
                            while ($row = mysql_fetch_array($booktitle)) {
             
             
               
              $row_color = ($row_count % 2) ? $color1 : $color2;
              
               $row['$thesis'] = str_ireplace($search_text, $highlighted_text,$row['thesis']); //try removing $ sign or using some other variable

             
              if ($row['status'] == 'BORROWED')
              {
              $row_color = "#CCCCCCC";
              
              }
              
              else
              {
              echo "</tr>";
              }
                  
                               
                             
                             ?> 
                              <tr>
           
        <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['barcode'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['code'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2">
        <img src="thesis_icon.png" align="absmiddle" />&nbsp;&nbsp;<?php echo "<a href ='thesis_open.php?thesis_opener=".$row['thesis_recno']."'>";?><?php echo $row['title'];?></a></font></div></td>   
           
        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace"size="2"><?php echo $row['author'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['cright'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['course'];?></font></div></td>
             
             
        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['status'];?></font></div></td>
                             
             <?php
              
         
         
                             $row_count++;
            }
          

        MATIAS 'Mety' SORIANO
        MIS/IT Administrator/Consultant/Professor
        Contacts: Tel: (042)3736167 Cel: 09282860545
         


        --- On Thu, 29/7/10, Anjan Bhowmik <anjan011@...> wrote:

        From: Anjan Bhowmik <anjan011@...>
        Subject: Re: [phpXperts] Text Color in PHP
        To: phpexperts@yahoogroups.com
        Date: Thursday, 29 July, 2010, 12:32 PM


         
        When u get the row from result set u can aplly string replace ....

        $search_text = 'PHP';

        $highlighted_ text = '<span class="highlight">'.$search_text.'</span>'; // using the highlight css class u can do the text highlighting

        while($row = mysql_fetch_ row($result) )
        {
           // assuming the 'text' field contains book name, or description ...
          
           $row['text'] = str_ireplace( $search_text, $highlighted_ text,$row['text']);
        }

        // resume with rest of the code processing ....

        Hope this helps :)

        On Thu, Jul 29, 2010 at 8:31 AM, Mety <metysoriano@ yahoo.com> wrote:
         
        I want to highlight the word that I type in a text box. Example I would like to search the book that contains 'PHP', then all book that contains PHP will display BUT the the word PHP will BOLD or have different in color.

        Below is my code in quey a book

        $color1 = "#EEEEEE";
        $color2 = "#EEEEEE";
        $row_count = 0;






        while ($row = mysql_fetch_ array($booktitle )) {


        $row_color = ($row_count % 2) ? $color1 : $color2;



        if ($row['status'] == 'BORROWED')
        {
        $row_color = "#CCCCCCC";

        }

        else
        {
        echo "</tr>";
        }
        ?>



        <tr>

        <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['barcode'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['code'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="left"><font face="Courier New, Courier, monospace" size="2">
        <img src="thesis_icon. png" align="absmiddle" />&nbsp;&nbsp;<?php echo "<a href ='thesis_open. php?thesis_ opener=".$row['thesis_recno']."'>";?><?php echo $row['title'];?></a></font></div></td>

        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace"size="2"><?php echo $row['author'];?></font></div></td>
        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['cright'];?></font></div></td>

        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['course'];?></font></div></td>


        <td bgcolor="<?php echo $row_color;?>"><div align="center"><font face="Courier New, Courier, monospace" size="2"><?php echo $row['status'];?></font></div></td>

        Please help me.

        Thank you




        --
        Anjan Bhowmik
        Software & Web Development Department
        Ultra Soft
        Mobile : +8801670556419, +8801673636742
        Email : anjan011@gmail. com,info@ultrasoftbd. com


      • Mety Soriano
        I assigned variable thesis becuase it is the one who assigned in my text variable.  
        Message 3 of 10 , Jul 30, 2010
        • 0 Attachment
          I assigned variable 'thesis' becuase it is the one who assigned in my text variable.
           
          <input type="text" name = "thesis" size="38" style="font-weight:bold; font-size:20px"  onfocus="this.value=''" value="Type your THESIS QUERY here..."/><br />
           
          this input box is the do the query in searching a queries...
           
          Still did not work the one you give me sir
           


           
          MATIAS 'Mety' SORIANO
          MIS/IT Administrator/Consultant/Professor
          Contacts: Tel: (042)3736167 Cel: 09282860545
           


          --- On Fri, 30/7/10, Prerna Jain <prernajain83@...> wrote:

          From: Prerna Jain <prernajain83@...>
          Subject: Re: [phpXperts] Text Color in PHP
          To: phpexperts@yahoogroups.com
          Date: Friday, 30 July, 2010, 3:16 PM

           
          You are assigning to $row['$thesis' ]
          but you are not  printing it anywhere.

          Regards
          prerna


        Your message has been successfully submitted and would be delivered to recipients shortly.