将字符串传递给javascript函数然后显示onClick

I looked over some solutions, but I coudn't figure out how to get this solved here is my php

while($row = mysql_fetch_array($result))
{
   echo"<div class='span4'>
      <h2>$row[title]</h2>
      <p>$row[intro]</p>
      <p><a class='btn' onclick=parashow($row['contents'])>View details &raquo;</a></p>
    </div>";
}

I just want to pass the contents into (a function) and then this function display on click on div specific id

looking on the web for several hours couldn't help some say add {} other /' '/ or '''$row[contents]'''

stil no help

function parashow(x){

//document.getElementById('allrows').style.display = "none";
}

I don't know how to pass $row['contents'] to function argument and then get x and replace it into another div by id ('something')

Try this

while($row = mysql_fetch_array($result))
{
    echo"<div class='span4'>
    <h2>$row[title]</h2>
    <p>$row[intro]</p>
    <p><a class='btn' onclick=parashow('".$row['contents']."')>View details &raquo;</a></p>
    </div>";
}

It's good to generate HTML without PHP:

<?php while($row = mysql_fetch_array($result)) { ?>

    <div class='span4'>
        <h2><?php echo $row[title]; ?></h2>
        <p><?php echo $row[intro]; ?></p>
        <p><a class='btn' onclick="parashow('<?php echo $row['contents']; ?>')">View details &raquo;</a></p>
    </div>

<?php } ?>

try this

<?php while($row = mysql_fetch_array($result)) : ?>

    <div class='span4'>
        <h2><?php echo $row[title]; ?></h2>
        <p><?php echo $row[intro]; ?></p>
        <p><a href="#" class='btn' onclick="javascript:parashow('<?php echo $row['contents']; ?>')">View details &raquo;</a></p>
    </div>

<?php endwhile; ?>