Click to See Complete Forum and Search --> : Path variable linking to field name"


dcjones
08-26-2005, 11:00 AM
Hi all,

I am learning (FAST).

In php if I set a var to "$foo = "images/files";" as the path to my image directory and then I want to call the var in an echo statement, like:

<?php echo "<img src= \"$foo\" $row_midland_shires['coat_arms']"; ?>">

is this the correct way to write it?

Any help would be good.

Kind regards, keep safe and well.

Dereck

bokeh
08-26-2005, 11:09 AM
<img src="<?php echo $foo.$row_midland_shires['coat_arms']"; ?>">

dcjones
08-26-2005, 11:14 AM
Hi and thanks,

I know it was simple but some days so am I, many thanks again

RESOLVED

Dereck

dcjones
08-26-2005, 11:49 AM
Hi bokeh (not so resolved)

If I use:

<img src="<?php echo $arms_image.$row_midland_shires['coat_arms']; ?>">

the result is:

<div align="center"><img src="images/coat_of_arms/"></div>

It show the path but not the file, and the file is in the path.

Any ideas.

Kind regards again, keep safe and well.

Dereck

NogDog
08-26-2005, 11:57 AM
Or...

<?php
echo "<img src='$foo/{$row_midland_shires['coat_arms']}'>";
# ... or ...
echo '<img src="' . $foo . '/' . $row_midland_shires['coat_arms'] . '">';
# ... or ...
echo <<<EOD
<img src="$foo/{$row_midland_shires['coat_arms']}">
EOD;

# ... or ...
$file = $foo . "/" . $row_midland_shires['coat_arms'];
echo "<img src='$file'>";
# ... or ...
# etc., etc., and so forth.....
?>

As the Perl hackers always like to say, "There's more than one way to do it." :)

dcjones
08-26-2005, 12:08 PM
Hey Guys,

Thanks, its now working, my fault, I did not put the file name in the database.

Sorry for being an ass.

Kind regards, please keep safe and well.

Dereck