Hello everybody,
anyone can help me with this problem?
instead of just display the child (in array)..echo $Valuechild[$i]."; ";
(see the below code)..I would like to make a link from $Valuechild[$i] to a details of that variable..

<TEXTAREA NAME="comments3" style='width:50%' rows='4'>
<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
//$showsibling = $showsibling.$Valuechild[$i]."; ";
echo $Valuechild[$i]."; ";
?>	
<?php
}
?>	
</TEXTAREA>

I have done like this..

<a href="viewingdetails.php?name=<?php echo $Valuesibling[$i]."?></a>;

however there is an error on that line.
thank you

Recommended Answers

All 27 Replies

Is this what you mean?

<TEXTAREA NAME="comments3" style='width:50%' rows='4'>
<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
echo '<a href="viewingdetails.php?name='.$Valuechild[$i].'</a>';
}
?>	
</TEXTAREA>

thanks for your response.

Is this what you mean?

yes..I have tried this beforebut it appears like this:

<a href="viewingdetails.php?name=Science</a>	
<a href="viewingdetails.php?name=Matter in Nature</a>

what I need to do is to make a like from Science & Matter in Nature..or whatever .$Valuechild[$i]. is to a detail page.

hope someone can help me.

This: <a href="viewingdetails.php?name=<?php echo $Valuesibling[$i]."?></a>; Should be this: <a href="viewingdetails.php?name=<?php echo .$Valuesibling[$i].?>"</a>;

Should be this:

<a href="viewingdetails.php?name=<?php echo .$Valuesibling[$i].?>"</a>;

Hi,
I have tried that as well..but there is error on that line.
thanks anyway.
any other suggestion?

any other suggestion?

Could you please post the lines around $Valuechild=array(); and check that it also uses the right casing because I can only see half the picture here.

commented: thanks for your help..hope the problem could be solved..I have tried so many ways to make a link from that array variable +1

Hi..this is the code. I am sorry if this is not what you mean..
If it doens't..could you please explain..what should I provide here..thank you.

Is this what you mean?

<TEXTAREA NAME="comments3" style='width:50%' rows='4'>
<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
echo '<a href="viewingdetails.php?name='.$Valuechild[$i].'</a>';
}
?>	
</TEXTAREA>

Hi there, from the past couple of posts, you guys are on the right track, it just seems that no-one remembered to close the anchor tag properly, it should be like this:

#
<?php
#
for ($i =0; $i < $ValuenumtableChildren; $i++)
#
{
#
echo '<a href="viewingdetails.php?name='.$Valuechild[$i].'">LINK TEXT GOES HERE</a>';
#
}
#
?>

hi..
I have tried that one as well..
the same output displayed.. (as below) <a href="viewingdetails.php?name=Matter in Nature">LINK TEXT GOES HERE</a> Matter in Nature should be underlined, to be linked to the detail page.

any help??
thanks

It could be the spaces, run the values thru the htmlentities() function
and try again, but i can't see any reason why that link wouldn't work as it is in your last post.

Hi Menster.,
thanks for your suggestion but I am not really understand what is it..
Could you help me with this?

It could be the spaces, run the values thru the htmlentities() function
and try again,

thanks a lot

Sure thing, try this:

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
$value = htmlentities($Valuesibling[$i]);
echo "<a href=\"viewingdetails.php?name=".$value."\"</a>";
}
?>

htmlentities() takes special characters (like < > @ # $ % etc.) and changes them to their html escape codes, for example '<' is translated into '&lt;'. This will help the browser see that the space in your link's target doesn't terminate the tag.

Hi menster,
thanks for your explanation..anyway,the same result displayed

href="viewingdetails.php?name=Matter in Nature"</a>
what else should I do?:S

Hi,
you should try like this;

      <?php
      for ($i =0; $i < $ValuenumtableChildren; $i++)
      {
    ?>
    <a href="viewingdetails.php?name= <?php echo $value[$i]?> "> <?php 
    echo $value[$i]?></a>

    <?Php  }
          ?> 

By any chance would the variable $ValuenumtableChildren = 0 or something like that. Also make sure that the array $valuechild[] actually exists. So try the below script if your not using mysql for the data.

<?php
if (empty($Valuechild) || !isset($Valuechild)) {
die('$Valuechild is not a valid variable. That is whats causing the problem.');
} 
foreach ($Valuechild AS $val) {
echo '<a href="viewingdetails.php?name='.$val.'>'.$val.'</a>';
}
?>

If you are using mysql and are displaying the results in a loop then the following would apply:

<?php
while ($row=mysql_fetch_array($sqlresult)) {
echo '<a href="viewingdetails.php?name='.$row[0].'>'.$row[0].'</a>';
}
?>

Hope that helps.

Also make sure that the array $valuechild[] actually exists.

hi,
$Valuechild[$i] is a valid variable..the output is displayed..
ie: Matter in Nature

the problem is that the output is not as what expected..
It should be like this
Matter in Nature

however the output displayed is like this..

<a href="viewingdetails.php?name=Matter in Nature</a>.

href is appear in the output..it should be a link , shouldn't it?

many thanks for your help

If that's all that the problem is then the following should do the job:

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
echo '<a href="viewingdetails.php?name='.$Valuechild[$i].'">'.$Valuechild[$i].'</a>';
}
?>

If the above code doesn't displaying anything at all then try the code in my previous post.

If that's all that the problem is then the following should do the job:

the output is similar as what I got before
<a href="viewingdetails.php?name=Matter in Nature">Matter in Nature</a>

not Matter in Nature..

I do not know what else can I do..huhu

Then could you specify with html code in a code box what you would like the output to be?
I will guess what you want again. The following will just an underlined piece of text without a link.

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
echo '<u>'.$Valuechild[$i].'</u><br>'."\n";
}
?>

and the following will do the same without the underline:

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
echo $Valuechild[$i]."\n";
}
?>

Updated the code

yes..I know that..I just to make an underline
but What I intend to do is to make a link from that variable [Childvalue]to a detail page..

I just to make an underline
but What I intend to do is to make a link from that variable

it was a typing mistake..
It just to make an underline
but What I intend to do is to make a hyperlink from that variable to a detail page.

someone has commented this..

Your problem is that you are trying to have a link inside a textarea.

Bottom line is that textareas are for editing, so HTML isn't rendered inside them.

maybe javascript can solve this?
any input?
many thanks

If your trying to place html code inside a textarea box then you will need to use Java (not Javascript). This is because it is impossible for html/javascript/css to display the links in the textarea as found in a google search however I have seen examples of it being done in Java though. That is why on every forum you see bbcode instead of dynamically formated text in the textarea field.

thanks guys for your help, suggestions, comments etc.
however it is still unsolved.

thanks anyway

Hello,
since there is no solution for a link in text area..
I just make it a normal link-not in textarea

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
echo '<a href="view.php?name='.$Valuechild[$i].'">'.$Valuechild[$i].'</a>';
  }
?>

the output is correct....ScienceMatter in Nature ( with a link to appropriate record.
BUT..how to display it in different line like this:
Science
Matter in Nature..

many thanks for your help.

Hi again,
To do that you would need to but a "<br/>" between Science and Matter. This is quite simple:

$str1 = substr($Valuechild[$i],0,7);
$str2 = substr($Valuechild[$i],8);
$final_str = $str1."<br/>".$str2;

However, it'll be a lot trickier when the lengths of your words vary.

thanks Menster..
I have tried like this

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
      $str1 = substr($Valuechild[$i],0);
      $str2 = substr($Valuechild[$i],1);
      $final_str = $str1."<br/>".$str2;	
printf ('<a href="view.php?name=%s"></a>' ,$ $final_str , urlencode($string) );     
    }
?>

but this time nothing appear as an ouput..

Try it like this:

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
      $str1 = substr($Valuechild[$i],0,7);
      $str2 = substr($Valuechild[$i],8);
      $final_str = $str1."<br/>".$str2;	
echo "<a href=\"view.php?name=$Valuechild[$i]\">$final_str</a>";
    }
?>

Thanks all..
I have done this ..not in text area.
just a normal link..using the same syntax & then print <br/> at the end of that code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.