Jump to content

Archived

This topic is now archived and is closed to further replies.

kevloink

Variables

Recommended Posts

Can you use variables in sql statments, or links? Like 'a href=$varhere' Or SELECT #varhere FROM table.

Share this post


Link to post
Share on other sites
indeed you can, just make sure you put: a href="<? echo $variable; ?>" if the link is not in a php statement already

Share this post


Link to post
Share on other sites
[quote author=kevloink link=topic=103743.msg413355#msg413355 date=1155231491]
Can you use variables in sql statments, or links? Like 'a href=$varhere' Or SELECT #varhere FROM table.
[/quote]

as long as you echo the variable in such a way that it will be translated, yes indeed.

for instance:
[code]
<?php
// these will work:
echo "<a href=\"$myLink\">Some Link Text</a>";
$sql = mysql_query("SELECT $myColumn FROM tableName");

// this will not:
echo '<a href="$myLink">Some Link Text</a>';
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.