| | |
need to make a link
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2006
Posts: 49
Reputation:
Solved Threads: 0
I am new to php and am building a search function for my website. The problem is I cannot seem to make the Aa> tags work to make the link I keep on getting parse error. could someone tell me how to make $title a link. I can pretty much do everything else from there. Thanks in advance.:!:
PHP Syntax (Toggle Plain Text)
while ($row = mysql_fetch_array($result)) { echo "<center><table>"; $count = 1 + $s; $title = $row["location"]; echo "<tr> <td>"; echo $title; echo "</td><td>"; echo "</td></tr>"; $count++; echo "</table></center>"; }
Last edited by lsu420luv; Oct 17th, 2006 at 8:03 pm.
Something like:
(I haven't tested that so I can't guarantee it being typo-free. PHP is unforgiving
)
PHP Syntax (Toggle Plain Text)
echo("<a href=\"mylink.htm\">$title</a>");
(I haven't tested that so I can't guarantee it being typo-free. PHP is unforgiving
) Last edited by SnowDog; Oct 17th, 2006 at 11:37 pm. Reason: Tidying text
•
•
Join Date: Mar 2006
Posts: 49
Reputation:
Solved Threads: 0
•
•
•
•
Something like:
PHP Syntax (Toggle Plain Text)
echo("<a href=\"mylink.htm\">$title</a>");
(I haven't tested that so I can't guarantee it being typo-free. PHP is unforgiving)
Thanks man. The link by the way is created dunamically do I have to use anytthing different to have a variable plug in the value rather than actually using the address.
Well, I assume that each incarnation of 'title' will have a different target url, so what do you think you will have to do for that...?
If we assume that 'title' is also the actual url as well as the link text, then:
If the url and the link text are different then you'll need to provide another variable or string of text for each iteration.
If we assume that 'title' is also the actual url as well as the link text, then:
PHP Syntax (Toggle Plain Text)
echo("<a href=\"$title\">$title</a>");
If the url and the link text are different then you'll need to provide another variable or string of text for each iteration.
•
•
Join Date: Mar 2006
Posts: 49
Reputation:
Solved Threads: 0
when the user does the search he/she selects a system to search under. then that is put through a switch statement and the $var variable determines the address i.e. www.foo.bar/nes/roms/ the $title is then put in after from the location field of the table and the hyperlink works. I have it tell me the right location I just have not been able to make it a link. Thanks for all your help. The problem was not the link but making the dynamic table with the link included. I got confused with alll the echos and other punctation marks. Thanks for all your help.
•
•
Join Date: Mar 2006
Posts: 49
Reputation:
Solved Threads: 0
It is giving me an error. This is what I entered:
IT gives me this error:
What am I doing wrong>
PHP Syntax (Toggle Plain Text)
$title = $row["location"]; echo "<tr> <td>"; echo "<a href="$link$title">$title</a>"; echo "</td><td>"; echo "</td></tr>"; $count++;
IT gives me this error:
PHP Syntax (Toggle Plain Text)
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /var/www/web2/web/romSite/process.php on line 123
What am I doing wrong>
You can't use " inside the echo - you have to escape any occurence of " with \", so that line in the middle should be:
Otherwise PHP thinks the echo has ended and gets messed up. And you should put ( and ) each end of the echo containing the "s which are part of the syntax.
Same on your other lines - put the ( and ) in. So:
But I'm also a bit confused about $link$title in the anchor tag. What would each variable typically contain in an iteration?
PHP Syntax (Toggle Plain Text)
echo ("<a href=\"$link$title\">$title</a>");
Otherwise PHP thinks the echo has ended and gets messed up. And you should put ( and ) each end of the echo containing the "s which are part of the syntax.
Same on your other lines - put the ( and ) in. So:
PHP Syntax (Toggle Plain Text)
$title = $row["location"]; echo "<tr><td>"; echo ("<a href=\"$link$title\">$title</a>)"; echo ("</td><td>"); echo ("</td></tr>"); $count++;
But I'm also a bit confused about $link$title in the anchor tag. What would each variable typically contain in an iteration?
Last edited by SnowDog; Oct 19th, 2006 at 11:04 pm.
•
•
Join Date: Mar 2006
Posts: 49
Reputation:
Solved Threads: 0
thanks a lot man. I was wondering what all the wierd characters. I am used to c++. It is a little more plain than this. Shockingly similar though like the switch statement is almost the same as one I built for c++ class. Well thanks. I am really glad you explained why so now I can apply that to other things. Thanks again
•
•
•
•
It is giving me an error. This is what I entered:
PHP Syntax (Toggle Plain Text)
$title = $row["location"]; echo "<tr> <td>"; echo "<a href="$link$title">$title</a>"; echo "</td><td>"; echo "</td></tr>"; $count++;
IT gives me this error:
PHP Syntax (Toggle Plain Text)
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /var/www/web2/web/romSite/process.php on line 123
What am I doing wrong>
Hi,
YOu can also use it like
echo "<a href="{$link$title}">{$title}</a>";
Accouding to me when we require a output from a variable between double quotes use "<a href="{$link$title}">{$title}</a>";
Thankyou
![]() |
Similar Threads
- Travel Deal link swaps (Relevant Link Exchanges)
- Clicked Link Countdown (HTML and CSS)
- Link exchange with webhosting site (Relevant Link Exchanges)
- What is the best way to market a link exchange program? (Promotion and Marketing Plans)
- Link to page in page (HTML and CSS)
- How did Dani get the "Search" link to go directly... (Existing Scripts)
- Link to resources (Search Engine Optimization)
Other Threads in the PHP Forum
| Thread Tools | Search this Thread |
advanced alerts apache api archive array autosuggest beginner binary broken cakephp checkbox class clients cms code cron curl database date datepart display dynamic echo email emptydisplayvalue eregi error execute explodefunction file files folder form forms function functions google hack href htaccess html if...loop image include insert ip javasciptvalidation javascript joomla keywords library limit link login mail matching menu mlm multiple mysql object oop password paypal pdf php phpincludeissue query radio random recursion recursive remote script search searchbox server sessions shot smarty sms source space speed sql syntax system table tutorial update upload url validator variable vbulletin video web website youtube





