FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Image tag with PHP inside help





Asap170
Okay so here is my source code.

Code:
<?php
                    // Link to 'images' folder
                        $link = "gradebook/images/navigation";
                       
                    // URL of pages to display the correct images
                        $home = "/~blake/gradebook/index.php";
                        $grades = "/~blake/gradebook/grades.php";
                        $report = "/~blake/gradebook/report.php";

                    // Get the address of your page
                        $adr = $_SERVER['PHP_SELF'];

                    // Display which page you are viewing
                        if($home == $adr){
                            echo "<img id='home' border='0' src='themes/<?php echo $link ?>/home_tab.png?>";
                            echo "<img id='grades' border='0' src='themes/<?php echo '$link'/grades.png ?>";
                            echo "<img id='report' border='0' src='themes/<?php echo '$link'/report.png ?>";
                            echo "<img id='logout' border='0' src='themes/<?php echo '$link'/logout.png ?>";
                        }else if($grades == $adr){
                            echo "<img id='home' border='0' src='<?php echo '$link';/home.png ?>";
                            echo "<img id='grades' border='0' src='themes<?php echo $link'/grades_tab.png ?>";
                            echo "<img id='report' border='0' src='themes<?php echo '$link'/report.png ?>";
                            echo "<img id='logout' border='0' src='themes<?php echo '$link'/logout.png ?>";
                        }else if($report == $adr){
                            echo "<img id='home' border='0' src='<?php echo '$link'/home.png ?>";
                            echo "<img id='grades' border='0' src='<?php echo '$link'/grades.png ?>";
                            echo "<img id='report' border='0' src='<?php echo '$link'/report_tab.png ?>";
                            echo "<img id='logout' border='0' src='<?php echo '$link'/logout.png ?>";
                        }else{
                            echo "<img id='home' border='0' src='<?php echo '$link'/home.png ?>";
                            echo "<img id='grades' border='0' src='<?php echo '$link'/grades.png ?>";
                            echo "<img id='report' border='0' src='<?php echo '$link'/report.png ?>";
                            echo "<img id='logout' border='0' src='<?php echo '$link'/logout.png ?>";
                        }
                ?>


My trouble is that the images won't show up I get
Code:
<?php echo
It's like that it doesn't want to read my PHP but it does/doesn't

Does anyone know how to fix this? Thanks in advance.
Peterssidan
It looks like you tries to open a new PHP section inside another PHP section. You can't do that. if we take this row:
Code:
echo "<img id='home' border='0' src='themes/<?php echo $link ?>/home_tab.png?>";

You can put the $link variable directly inside the string when using double quotes and it will expand automatic. Also I can't understand why you have ?> after "home_tab.png". Maybe something like this is what you want:
Code:
echo "<img id='home' border='0' src='themes/$link/home_tab.png'>";
Asap170
Yes! Thank you!
Related topics
Uplaoding images using php form :::: Help needed
PHP inside Javascript
php project help needed please
Help with php and java script
php script help!
PHP installtion Help!
Opening any image with PHP. Couldn't find anywhere.
upload image through PHP AND AJAX
A Little PHP GD Help...
Image Editing (PHP)
PHP inside HTML tags?
Random image for your gallery
can you help me?
How to center something horizontally AND vertically...
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.