Forums

problem with if statement and variables in cc

mja1356 08 May, 2009
Hi
sorry for repeating my problem๐Ÿ˜Ÿ๐Ÿ˜Ÿ๐Ÿ˜Ÿ there was no response to my question then i think that i must create a new topic with appropriate head.
this is my code in body area



        <tr dir='ltr'>
       
          <td>{cat}</td>
          <td>{recordtime}</td>
          <td>{game}</td>
         <td>
        
       
          <?php
          
          $host="{HG}";
          echo $host;
          if ($host=2)
          echo 'hi';
          elseif ($hoost=1)
          echo 'bye';
       
        ?>
       </td>
        
    <td>{tip}</td>
      <td>{win}</td>
       <td>{loss}</td>
        <td>{ex1}</td>
        <td>{odd}</td>
        <td>
        <?php
          $tip='{tip}';
          echo $tip;
             if ( $tip=='ft' || $tip=='Over/Under')
             {
          
                echo '{ftga}-{ftgb}';
              } else {
          
                echo '{htga}-{htgb}';
              }

         
        ?>
       </td>

    <td>{stats}</td>
          </tr>
         




my problem is that if statement doesn't work .I mean when I echo $host variable it changes in every record in output but it doesn't execute php code inside if statement.
I can do this with CF very easily but because i have many records in DB i need CC pagination to limit output.triumph, do boi, winny, thoi trang be gai, xe day tre em, do dung cao cap cho be, thoi trang cong so, vay lien cong so, ban buon quan ao, do lot[/url]
anyway can i use some kind of pagination in CF?๐Ÿคจ
peter49 15 May, 2009
Hi mja1356,

your first if statement won't do what you might have in mind, as it is incorrect.
A (syntactically) correct version is:

if ($host==2)
  echo 'hi';
elseif ($host==1)
  echo 'bye';

Please note that this code will only produce any output when $host equals either 1 or 2. In all other cases you'll see nothing at all. A better approach could be to add an else clause that catches all other cases.

if ($host==2)
  echo 'hi';
elseif ($host==1)
  echo 'bye';
else
  echo 'Unexpected value: '.$host;


Success!
This topic is locked and no more replies can be posted.