php if

doctorbill
doctorbill used Ask the Experts™
on
Code trial 1:
------------------
$img_path = 'ticktockInt/images/jpg/exclaim.jpg';  

<tr>
           
<td colspan="12" align="center" class="body_bold_black"><a name="remimage" id="remimage"></a>
 <?php if ($row_invoicesReminders['Reminder'] == "Remind") {
                    echo "<li><img src='$img_path;'/><li>";  } ?>
               

       </tr>
        <tr>

Code trial 2:
------------------

$img_path = '<img src="ticktockInt/images/jpg/exclaim.jpg" width="102" height="102" />';

<td>
             
               <?php if ($row_invoicesReminders['Reminder'] == "Remind") {
                    echo $img_path;  } ?></td>
            </tr>


I do not get any errors
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Marco GasiFreelancer
Top Expert 2010

Commented:
Php is case-sensitive: are you sure the value should be 'Remind' and not 'remind'? And the same quetion can be done about the column name...
Marco GasiFreelancer
Top Expert 2010

Commented:
Can you show the whole code: query and loop?

Author

Commented:
<?php do { ?>
            <tr>
              <td align="left" valign="top" class="totals"><?php echo $row_invoicesReminders['ID']; ?></td>
              <td align="left" valign="top" class="totals"><?php echo $row_invoicesReminders['Name']; ?></td>
              <td align="left" valign="top" nowrap="nowrap" class="totals"><?php echo $row_invoicesReminders['Date']; ?></td><td>
             
               <?php if ($row_invoicesReminders['Reminder'] == "Remind") {
                    echo $img_path;  } ?></td>
            </tr>
            <?php } while ($row_invoicesReminders = mysql_fetch_assoc($invoicesReminders)); ?>
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Fixer of Problems
Most Valuable Expert 2014
Commented:
I don't know why you think there should be errors but this line...

echo "<li><img src='$img_path;'/><li>";

needs to have the ';' after $img_path removed.

echo "<li><img src='$img_path'/><li>";
Marco GasiFreelancer
Top Expert 2010

Commented:
Try this

if (trim($row_invoicesReminders['Reminder']) == "Remind")

Open in new window


Maybe there is some hidden space in your database column...

Author

Commented:
Dave:
If I just put this into the page:
echo "<img src='$img_path'/>";  } ?>

I get the inage
So it vlooks as if there is a problem with the IF statement
Marco GasiFreelancer
Top Expert 2010

Commented:
Did you try to use trim as I suggested above?

Author

Commented:
Sorted:
I edited my recordset - it was not referencing all the fields correctly (specifically thyhe "Reminders" field

Author

Commented:
completed
Marco GasiFreelancer
Top Expert 2010

Commented:
What is the solution? Editing the recordset (and how?) or deleting a semicolon? I'm missing something here...
Most Valuable Expert 2011
Top Expert 2016

Commented:
Going forward, a useful concept in PHP programming is the use of HEREDOC notation to make templates and HTML fragments that are later used in creating a complete web page.  Once you know how this works, it will revolutionize your programming and design practices.  Just a thought...
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Author

Commented:
Marco:
The solution was to edit the recordset and get rid of the ";"
Marco GasiFreelancer
Top Expert 2010

Commented:
Thanks for the explanation :-)

Author

Commented:
Thanks Ray

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial