1

I have result php page with a html table. Inside row[3] i have spoilers. if i click on a text value i can see hidden content.
Inside hidden content i have links on different lines
To make this:
- I insert text inside mysql textarea, so:

enter image description here
- Then I add javascript code in <head>section

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
   <script type="text/javascript">
$(function() {
        $(".spoiler-label").click(function() {
        $(this).parent().find(".spoiler-content").toggle();
    });
    });
</script>

- and then php code:

echo '<td><span class="spoiler-label">'.$row[1].'</span><div class="spoiler-content" style="display: none"><br><a href='.$row[3].'<a/></div><td>';

- To break the text in new lines i use this php code:

    $row['3']=stripslashes($row['3']);
    $row['3']=str_replace('<br />',"newline",$row['3']);
    $row['3']=htmlentities($row['3']);
    $row['3']=str_replace('newline',"<br>",$row['3'])

i obtain this final result:

enter image description here

but you can see the problems:

- formatting is missing because the <th> of row X is black and not orange
- the links inside the spoiler are 2 but are treated as if they are one link.
- i have not correctly link because google.com is http://google.com<br WHY?
You can see 2 links:
http://alfa.com
http://google.com
but if i click over http://alfa.com the link is always http://google.com<br
I want:
-remove <br from link
-separate one link into different links (alfa.com & google.com)
-repair incorrect row formatting

This is my page complete code http://pastebin.com/zb22VqwD and this css http://pastebin.com/dFRFURGM

1
  • -1 for long non-abstracted localised question; +1 for the effort of putting together a complete post with annotated graphics! Oct 22, 2012 at 13:17

2 Answers 2

1

first off, your 1 line php code echo is wrong (u didnt close <a>). The css didnt work because of this.

(i removed the first echo)

second, an <a> tag cannot have another <a> tag inside it, so you should just remove the whole <a> from your code above, meaning it should be:

echo '<td><span class="spoiler-label">'.$row[1].'</span><div class="spoiler-content" style="display: none"><br>'.$row[3].'</div><td>';

then, when instead of for some reason changing ur correct <br/>'s into the old version <br> tag, use the tag to create an array:

$ary=explode('<br />',$row['3']);
$str="";
foreach($ary as $str2){
$str.="<a href=\"$str2\">$str2</a><br/>";
}

and then echo $str into the row,

Your code should be:

$row['3']=str_replace('<br />',"newline",$row['3']);
$row['3']=stripslashes($row['3']);
$row['3']=htmlentities($row['3']);
$ary=explode('newline',$row['3']);
$str="";
foreach($ary as $str2){
    $str.="<a href=\"$str2\">$str2</a><br/>";
    //$str.="$str2<br/>";
}
$row['3']=$str;
7
  • Can u show me with my code, please? i don't undestand how code, thanks for help anyway
    – user143822
    Oct 22, 2012 at 13:06
  • now the links are separated but i have still css problems and i have double links? look here imageshack.us/a/img266/8265/solmk.png this is my code updated pastebin.com/v0ysisex What did I do wrong?
    – user143822
    Oct 22, 2012 at 13:24
  • i don't change <br/> into <br> could be? if so, in what sense do I change it into <br>?, what part of the code you're referring to?
    – user143822
    Oct 22, 2012 at 13:31
  • actually u accidently put double the code..see my changes again. at the top, and bottom
    – we.mamat
    Oct 22, 2012 at 13:34
  • mm..something seems to have improved, but still have some problems with the double link on download column download link and with css, look please imageshack.us/a/img713/7875/css2o.png with your correction pastebin.com/a3z4hpM4 what's wrong?
    – user143822
    Oct 22, 2012 at 13:39
0

You are use beolow code:

$row['3']=stripslashes($row['3']);
$row['3']=str_replace('<br />',"newline",$row['3']);
$row['3']=htmlentities($row['3']);
$row['3']=str_replace('newline',"<br>",$row['3'])

Instead of above code use below:

$row['3']=str_replace('<br />',"newline",$row['3']);
$row['3']=stripslashes($row['3']);
$row['3']=htmlentities($row['3']);
$row['3']=str_replace('newline',"<br>",$row['3'])

Just replace first line to second and second line to first..just try...hope this help..

1
  • mmm..if i try to replace Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\xampp\htdocs\test2\test\zzz\risultati0.php on line 127 is normal?
    – user143822
    Oct 22, 2012 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.