Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Variable Value

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Postby bezmond » Sat May 03, 2003 8:11 am

try:

<td><a href="handlecity.php?sid=<? echo $sid ?>&vcity=<? echo $Row['city'] ?>&vstate=<? echo $Row['state'] ?>"><? $Row['city'] ?></a></td><br>

That's a different way of writing it and usually works for me.

Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby bezmond » Sat May 03, 2003 8:12 am

that's instead of your first echo line by the way.

Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby bezmond » Sat May 03, 2003 11:11 pm

try just putting echo $sid; somewhere else in your coding... check it's being set correctly...

Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby bezmond » Sun May 04, 2003 12:02 am

I guarentee to you that this DOES work:

Code: Select all
<?
$sid = 1;
 print ("<tr>\n");
      ?> <td><a href="handlecity.php?sid=<? echo $sid ?>&vcity=<? echo $Row["city"]; ?> ?>&vstate=<? echo $Row["state"];

?>"><? echo $Row["city"]; ?></a></td><br>
      <td><a href="handlecounty.php?sid=<? echo $sid; ?>&vcounty=<? echo $Row["county"]; ?>&vstate=<? echo $Row["state"];

?>"><? echo $Row["county"] ?></a></td><br> <?
      print ("</tr>\n");
?>


I've tested it locally by declaring a load of variables... and it works... :)

Regards,
Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby pootergeist » Sun May 04, 2003 12:14 am

quick explaination...

echoing lines encased in single quotes will not substitute $var-val pairs as the line isn't interpreted - php only interprets double quote encased lines...

$var = 'value';
echo "$var"; // ===> value
echo '$var'; // ===> $var
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

Postby MithikoS » Sun May 11, 2003 9:00 pm

print ("<tr>\n");
echo ('<td><a href="handlecity.php?sid=$sid&vcity='.$Row['city'].'&vstate='.$Row['state'].'">'.$Row['city'].'</a></td>'."\n");
echo ('<td><a href="handlecounty.php?sid=$sid&vcounty='.$Row['county'].'&vstate='.$Row['state'].'">'.$Row['county'].'</a></td>'."\n");
print ("</tr>\n");


i thing this is match better :)

<?php
$Row[1]= "test";
$sid=1;
echo "<table><tr><td><a href=handlecity.php?sid=". $sid. "&vcity=" .$Row[1]. "&vstate=" .$Row[1].">".$Row[1]."</a></td></tr></table>";
?>

i use $row[1] for the Row['state'] etc

You don't need to write all this thing <?php echo etc ?>
One echo is enough :)
MithikoS
New php-forum User
New php-forum User
 
Posts: 8
Joined: Sun May 11, 2003 7:56 pm
Location: London

Postby bezmond » Sun May 11, 2003 10:38 pm

I know one echo is enough, I just find it easier to do that so I don't have to remember to change "" to '' etc, hehe

Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Postby Redcircle » Tue May 20, 2003 1:36 am

print ("<tr>\n");
echo ('<td><a href="handlecity.php?sid=$sid&vcity='.$Row['city'].'&vstate='.$Row['state'].'">'.$Row['city'].'</a></td>'."\n");
echo ('<td><a href="handlecounty.php?sid=$sid&vcounty='.$Row['county'].'&vstate='.$Row['state'].'">'.$Row['county'].'</a></td>'."\n");
print ("</tr>\n");


here

Code: Select all
print ("<tr>\n");
      echo ('<td><a href="handlecity.php?sid='.$sid.'&vcity='.$Row['city'].'&vstate='.$Row['state'].'">'.$Row['city'].'</a></td>'."\n");
      echo ('<td><a href="handlecounty.php?sid='.$sid.'&vcounty='.$Row['county'].'&vstate='.$Row['state'].'">'.$Row['county'].'</a></td>'."\n");
      print ("</tr>\n");


all I did was add '. before $sid and .' after
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron