Re: Retrieving Image Location in PHP from MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



haliphax wrote:
On Mon, Mar 9, 2009 at 8:43 PM, Sashikanth Gurram <sashi34u@xxxxxx> wrote:
Is there any way in which I can assign a variable to a query string?
Like for example, Let us say that there are two php files a.php and
b.php. I am currently using a image tag like <img
src="imgtest.php?id=Williams Hall" /> in a.php and am passing the value
to another variable using $build=$_GET['id']; in b.php. Now for this
purpose, I am using the img tag in the html part of my first file which
makes it kind of static. Now if I want to assign a variable (say
$building) to 'id' in my first file, and retrieve it using the  variable
$build in the second file what is the best way to do it?
Will the command (written  inside the PHP tags) echo ' <img
src="imgtest.php?id=$building />'; be of any help in performing the
task. I have actually tried this out, but it did not work for me (May be
my syntax is wrong although I have tried various combinations). So, is
there a better way or correct way of doing this (If what I have done is
wrong). I have tried to use $_session() command, but it is kind of
yielding me a header error.

I'm not sure if this has been addressed in any of the other replies,
but I felt it was worth mentioning: Be careful and pay attention to
whether you are using single quotes ( ' ) or double quotes ( " ) in
your echo statements!

$var = 'asdf';
echo 'hey, $var'; // "hey, $var"
echo "hey, $var"; // "hey, asdf"

...and if you're using single or double quotes elsewhere (i.e.,
assignment operations)...

$var = 'asdf';
$othervar = 'blah$var'; // "blah$var"
$anothervar = "blah$var"; // "blahasdf"
$yetanothervar = "blah{$var}blah"; // "blahasdfblah"

Double quotes, when not using "echo", can still parse variables for you.


Thanks, Haliphax. I knew this stuff from janet valede's PHP for dummies.
-Sashi

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sashikanth Gurram
Graduate Research Assistant
Department of Civil and Environmental Engineering
Virginia Tech
Blacksburg, VA 24060, USA


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux