|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Hyperlink Mailto: field help
I have set up a database from the tutorial for multicolumn output. http://codewalkers.com/tutorials/15/1.html All is well (finally) except I am trying to create a link from an e-mail address field to the mailto: function.
My code: $data9 is the email address. I want to create the link "<a href="mailto:myadress@mysite.com">myaddress</a>" The line above works if I substitute text for the second instance of $data9, but I get an "Array" link to my e-mail address with the code that I have. What am I doing wrong? Thanks for any help you can give. |
|
#2
|
|||
|
|||
|
RE: Hyperlink Mailto: field help
Not quite sure what $data9 contains - but it is an array, so when you use $data9[$i + ($j * $rows)] it puts element $i + ($j * $rows) (I take it that this is something along the lines of myadress@mysite.com)
When you say just $data9 - you do not specify which array element - so it just says 'hey - im an array'! Basically - you are not saying which part of the array to display, just displaying the array as a whole. If you wanted it to display myadress@mysite.com as the link then change the code to [ Code:
echo "<a href="mailto:".$data9[$i + ($j * $rows)]."">$data9[$i + ($j * $rows)]</a>" . "<P></TD>n"; If you wanted it to display a differnt element of $data9 then I would need to know what $data9 contains - do a print_r($data9) and post - then I'll try to help |
|
#3
|
|||
|
|||
|
RE: Hyperlink Mailto: field help
Thanks for your reply.
When I tried that approach I got "Parse error: parse error, expecting `']'' in /usr/local/etc/httpd/htdocs/editor/search.php on line 183" which is the line that I am having trouble with. $data9 is the e-mail address from the email field. Before the link worked as long as I put text in the link like this. What I am trying to do is to put the same e-mail address that is the link in the text portion link. |
|
#4
|
|||
|
|||
|
RE: Hyperlink Mailto: field help
Yes - sorry, was a long day yesterday
You need to end your quote marks exactly like you did with the first use of $data9 to act as the href, i.e. Code:
echo "<a href="mailto:".$data9[$i + ($j * $rows)]."">".$data9[$i + ($j * $rows)]."</a><P></TD>n"; This should now work... Don't forget as well, that you can use single quotes within double quote marks, and vice versa so you could do: echo '<a href="blahdyblahdy">Click Here</a>' and it gets rid of the need for doing /" whenever you need a string within what your outputting... So your code could be: Code:
echo '<a href=mailto:'.$data9[$i + ($j * $rows)].'>'.$data9[$i + ($j * $rows)].'</a><P></TD>' Which should do two things - over longer string concatination, it should help to read the code for debugging. Also the code should parse faster as php will look within any "" strings for variable names i.e. $var1, and will parse the variable name into the value it holds (e.g. the number 5). ''s don't care - they just treat the whole lot as text and output it regardless! This means echo 'value: $var1' would just display like: value: $var1 whereas echo "value: $var1" would display like: value: 5 Hope this helps, J |
|
#5
|
|||
|
|||
|
RE: Hyperlink Mailto: Solved
Jester,
Thanks a lot you found what I had been missing. It works great now and I can reuse that code for some other fields that I need. The part that I like is that if the field is empty it just leaves a blank with no empty "Mail To:" text or anything to mislead anyone. Thanks again. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Hyperlink Mailto: field help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|