|
-
Aug 15th, 2002, 08:05 AM
#1
Thread Starter
Fanatic Member
correct way to write this
Not sure exactly how to write this correctly.
I have some text and the link for it should be as follows:
href="$_REQUEST['cats'] & view.php? & echo $record['id']"
now obviously I can't use & to seperate the pieces but how would I write this correctly?
the "view.php?" is just regular text
thanks
-
Aug 15th, 2002, 08:43 AM
#2
PowerPoster
. is the concatenation character
e.g
$greeting = 'Hello ' . $name;
-
Aug 15th, 2002, 10:46 AM
#3
Thread Starter
Fanatic Member
i tried something like this:
Code:
<p align="center"><b><a href="<?php $_REQUEST['cats'] . 'view.php?' . echo $record['id']?>"><BR><?php echo $record['title']; ?></a></b></p>
and i get an error 
it should take what i posted "cats" and then add the text view.php? and then the releated id that i am pulling from a query and it makes the url. The link should be the title.
any ideas what is wrong?
-
Aug 15th, 2002, 06:17 PM
#4
Fanatic Member
I like to use Print unless it is really long.
<?php
print("<p align=\"center\"><b><a href=\"$_REQUEST['cats'] view.php?$record['id']?\"><BR>$record['title']</a></b></p>");
?>
-
Aug 15th, 2002, 06:38 PM
#5
PowerPoster
Originally posted by stickman373
any ideas what is wrong?
you're not printing the result. Try this:
PHP Code:
<p align="center"><b><a href="<?php print $_REQUEST['cats'] . 'view.php?' . $record['id'];?>"><BR><?php print 'Title: ' . $record['title']; ?></a></b></p>
-
Aug 17th, 2002, 11:55 PM
#6
Conquistador
or:
PHP Code:
echo "<a href=\"".$_REQUEST['cats'].'view.php?".$record['id']."\">Text</a>";
Should work too..
-
Aug 19th, 2002, 02:24 PM
#7
Addicted Member
Or
PHP Code:
href="<?=$_REQUEST["cats"] . "view.php?". $record["id"] ?>"
or even
PHP Code:
href="<?=$_REQUEST["cats"] ?>view.php?<?=$record["id"] ?>"
-
Aug 19th, 2002, 04:56 PM
#8
Conquistador
you don't need to "echo" it?
-
Aug 19th, 2002, 05:58 PM
#9
Addicted Member
Nah. You can do it like <%= %> in ASP (but obviously with question marks instead of percent signs).
You need to have short_open_tag = On defined in php.ini. It's also possible that they have disabled that functionality in later versions of PHP - I'm using 4.0.6 because I don't have access to upgrade our live servers and I'd like to keep the development server in sync with the live one.
-
Aug 20th, 2002, 01:50 AM
#10
Conquistador
-
Aug 20th, 2002, 01:59 AM
#11
Addicted Member
In this case
<?=literal ?>
can be used in place of
<? print(literal) ?>
like
<%=literal %>
can be used in place of
<% response.write literal %>
in ASP.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|