Hey Niro so I changed those lines and removed that code, I'm still working on it, same no function button. I think I understand the showContent function: That if the paragraph is visible when the button is clicked and the function runs, it will hide it. Otherwise it will show it. I'm not clear about the syntax but I'm trying to find more examples to understand it better.
For the line where I am creating the paragraph:
echo '<p id="comments_'.$post['post_id'].'" style="display:none">';
I tried changing it to:
echo '<p id="comments_'.$post['post_id'].'" style="color:red">';
to see if the paragraph was assigning it to the comments but that doesn't work, which makes me think that the paragraph isn't getting created for some reason.
<?php get_header ();?>
<script language="javascript" src="jquery.js"></script>
<script language="javascript">
function showContent(ref)
{
if($("#comments_"+ref).is(':visible'))
{
$("#comments_"+ref).hide('slow');
}
else
{
$("#comments_"+ref).show('slow');
}
}
</script>
<div id="logger">
<?php
if ( is_user_logged_in() ) {
echo '<a href="http://www.hippievstony.com/wp-login.php?action=logout" style="text-decoration:none;">Log Your Ass Out</a>';
}
else {
echo '<a href="http://www.hippievstony.com/wp-login.php" style="text-decoration:none;">Log Your Ass In Here</a>';
echo '<p> OR </p>';
echo '<p><a href="http://www.hippievstony.com/wp-login.php?action=register" style="text-decoration:none;">Register So you Can Post Awesome Stuff Like All These Fools!</a></p>';
}
?>
</div>
<div id="box">
<?php
$qry = "SELECT u.id, user_nicename, post_date, post_content, post_title, post_type, post_excerpt, comment_content, comment_author, comment_approved, comment_count, comment_post_ID, comment_ID, wp_posts.ID as post_id
FROM wp_posts
INNER JOIN wp_users AS u ON post_author = u.id
LEFT JOIN wp_comments ON wp_posts.ID = comment_post_ID
WHERE post_type='post'
ORDER BY user_nicename ASC, post_date DESC";
$res = mysql_query($qry);
$author = array();
if ($res) {
while ($row = mysql_fetch_assoc($res)) {
$author[$row['user_nicename']][] = $row;
}
foreach($author as $k => $v) {
$orderbydate[$v[0]['post_date']][$k] = $v;
}
krsort($orderbydate);
foreach ($orderbydate as $k => $v) {
ksort($orderbydate[$k], SORT_STRING);
}
}
$divIds = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
$i = 0;
foreach ($orderbydate as $date => $authors) {
foreach ($authors as $author=> $posts) {
echo '<div id="'.$divIds[$i++].'">';
if($author=="tony") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/2009/12/tonyname.jpg">';
}
elseif($author=="hippie") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/2009/12/hippiename.jpg">';
}
elseif($author=="eriku") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/2009/12/erikuname.jpg">';
}
elseif($author=="ben") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/2009/12/benname.jpg">';
}
elseif($author=="hingyi") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/2009/12/hingyiname.jpg">';
}
elseif($author=="chris") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/chrisname.jpg">';
}
elseif($author=="gabe") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/gabename.jpg">';
}
elseif($author=="bender") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/bendername.jpg">';
}
elseif($author=="jake") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/jakename.jpg">';
}
elseif($author=="tim") {
echo '<img src="http://www.hippievstony.com/wp-content/uploads/timname.jpg">';
}
$lastPost = null;
foreach($posts as $post) {
if($lastPost != $post['post_id']) {
/*echo '<h2>' . $post['post_title'] . '</h2><small>' . $post['post_date'] . '</small>';*/
echo '<p>' . $post['post_content'] . '</p>';
/*echo '<p>' . $post['post_excerpt'] . '</p>'; */
$qry_prime = "SELECT COUNT(comment_post_ID) FROM wp_comments
WHERE comment_post_ID = '$post[post_id]'";
$res_prime = mysql_query($qry_prime);
$numberofresults = mysql_result($res_prime, 0);
mysql_query ("UPDATE wp_posts SET comment_count=$numberofresults WHERE wp_posts.ID = '$post[post_id]'");
$j=1;
}
$lastPost = $post['post_id'];
echo '<p id="comments_'.$post['post_id'].'" style="display:none">';
if($post['comment_approved']==1) {
echo '<p>' . $post['comment_content'] . '</p>';
echo '<p><small>-' . $post['comment_author'] . '</small></p>';
}
if($j>=$post['comment_count']) {
$post_id = $post['post_id'];
echo '<form method="POST" action="'.$_SERVER['PHP_SELF'].'"/>';
echo 'type it here <input type="text" name="commenty"/>';
if ($user_ID) {
$_POST[author]=$user_login;
echo '<input type="text" name="author" style="display:none" value="$user_login"/>';
echo '<p><input type="hidden" name="approval" value=1 /></p>';
echo "totally ready to comment as $user_login ยป ";
}
else {
echo '<p>name-o <input type="text" name="author"/></p>';
echo '<p><input type="hidden" name="approval" value=0 /></p>';
}
echo '<input name="submit_comment" type="submit" id="submit" value="fly like the eagle" tabindex="5" />';
echo '<p><input type="hidden" name="number_of_the_post" value="'.$post_id.'" /></p>';
if (empty($_POST['submit_comment']) || !(($post_id = (int) $_POST['submit_comment']) > 0)) {
# bad comment_ID;
}
if (isset($_POST['submit_comment'])) {
$_POST[commenty]=mysql_real_escape_string($_POST[commenty]);
$_POST[author]=mysql_real_escape_string($_POST[author]);
$_POST[number_of_the_post]=mysql_real_escape_string($_POST[number_of_the_post]);
mysql_query ("INSERT INTO wp_comments(comment_content, comment_author, comment_post_ID, comment_approved) VALUES ('$_POST[commenty]', '$_POST[author]', '$_POST[number_of_the_post]', '$_POST[approval]')");
}
$_POST['submit_comment']=NULL;
echo '</form>';
echo '</p>';
echo '<input type="button" name="cmdShow" id="cmdShow" value="Show / Hide" onclick="showContent('.$post['post_id'].');" />';
}
$j++;
}
echo '</div>';
}
}
get_sidebar ();
get_footer();
?>