organized 0 Denunciar post Postado Setembro 18, 2008 Fala galera! Essa é uma imagem de como tá os comentários no meu blog: http://img123.imageshack.us/my.php?image=coment01pd0.gifAté ai tudo mais que normal, ok? O que eu pretendo com a ajuda de vocês é adicionar uma caixa para as pessoas votarem no post, que ficaria como nessa foto: http://img517.imageshack.us/my.php?image=coment02yg3.gif O código dos comentários sem nota é o seguinte: <?php // Do not delete these lines if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); if (!empty($post->post_password)) { // if there's a password if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie ?> <p class="nocomments">This post is password protected. Enter the password to view comments.</p> <?php return; } } /* This variable is for alternating comment background */ $oddcomment = 'class="alt" '; ?> <!-- You can start editing here. --> <?php if ($comments) : ?> <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> <a href="#respond" title="<?php _e("Leave a comment"); ?>">»</a></h3> <ol class="commentlist"> <?php foreach ($comments as $comment) : ?> <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> <small class="commentmetadata"><cite><?php comment_author_link() ?></cite> on <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a><?php edit_comment_link('edit',' ',''); ?>:</small> <?php if ($comment->comment_approved == '0') : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> <?php comment_text() ?> </li> <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?> <?php endforeach; /* end for each comment */ ?> </ol> <?php else : // this is displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Comments are closed.</p> <?php endif; ?> <?php endif; ?> <?php if ('open' == $post->comment_status) : ?> <h3 id="respond">Leave a Reply</h3> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( $user_ID ) : ?> <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout »</a></p> <?php else : ?> <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" /> <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p> <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" /> <label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p> <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" /> <label for="url"><small>Website</small></label></p> <?php endif; ?> <!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>--> <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p> <p><input name="submit" class="button" type="submit" id="submit" tabindex="5" value="Submit Comment" /> <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> </p> <?php do_action('comment_form', $post->ID); ?> </form> <?php endif; // If registration required and not logged in ?> <?php endif; // if you delete this the sky will fall on your head ?> Essa é a imagem de como está o bando de dados atual sem nota: http://img178.imageshack.us/my.php?image=phpmyadm01ge0.gif Bom.. o que eu fiz pra tentar colocar esse sistema de notas até agora foi o seguinte: 1) Adicionei um campo na tabela do banco de dados chamada comment_nota do tipo VARCHAR(deve estar errado, me corrijam) 2) Adicionei algumas linhas no código, que não estão conectadas com o banco de dados, na verdade estou muito perdido :wacko: . Preciso da ajuda, por favor! <?php // Do not delete these lines if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); if (!empty($post->post_password)) { // if there's a password if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie ?> <p class="nocomments">This post is password protected. Enter the password to view comments.</p> <?php return; } } /* This variable is for alternating comment background */ $oddcomment = 'class="alt" '; ?> <!-- You can start editing here. --> <?php if ($comments) : ?> <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> <a href="#respond" title="<?php _e("Leave a comment"); ?>">»</a></h3> <ol class="commentlist"> <?php foreach ($comments as $comment) : ?> <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> <small class="commentmetadata"><cite><?php comment_author_link() ?></cite> on <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a><?php edit_comment_link('edit',' ',''); ?>:</small> <?php if ($comment->comment_approved == '0') : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> Nota do usuario: <?php comment_nota() ?> <?php comment_text() ?> </li> <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?> <?php endforeach; /* end for each comment */ ?> </ol> <?php else : // this is displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Comments are closed.</p> <?php endif; ?> <?php endif; ?> <?php if ('open' == $post->comment_status) : ?> <h3 id="respond">Leave a Reply</h3> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( $user_ID ) : ?> <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout »</a></p> <?php else : ?> <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" /> <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p> <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" /> <label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p> <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" /> <label for="url"><small>Website</small></label></p> <p><form name="form" id="form"> <select name="nota" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)"> <option value="10">10</option> <option value="9">9</option> <option value="8">8</option> <option value="7">7</option> <option value="6">6</option> <option value="5">5</option> <option value="4">4</option> <option value="3">3</option> <option value="2">2</option> <option value="1">1</option> <option value="0">0</option> </select> </form> <label for="nota"><small>Que nota voce da para este post?</small></label></p> <?php endif; ?> <!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>--> <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p> <p><input name="submit" class="button" type="submit" id="submit" tabindex="5" value="Submit Comment" /> <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> </p> <?php do_action('comment_form', $post->ID); ?> </form> <?php endif; // If registration required and not logged in ?> <?php endif; // if you delete this the sky will fall on your head ?> Quem tiver qualquer dica posta aqui por favor, muita gente tá querendo saber como se faz este sistema de comentários personalizado. Qualquer ajuda é muito bem-vinda! Compartilhar este post Link para o post Compartilhar em outros sites
PHDiniz 0 Denunciar post Postado Setembro 18, 2008 Tenta isso: Código pra selecionar a nota: <form method="POST" action="ok.php"> <div align="left"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="322" height="1"> <tr> <td width="73" height="1"><font face="Verdana" size="2">Nota:</font></td> <td width="243" height="1"><select size="1" name="nota"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select></td> </tr> </table> </div> <p><input type="submit" value="Submeter" name="B1"></p> </form> PHP pra colocar no MySQL (Arquivo ok.php): <?php //Conexão com o banco de dados $db = "host"; $db_usr = "usuario"; $db_pass = "senha"; $nota = $_POST["nota"]; $con = mysql_connect("$db", "$db_usr", "$db_pass") or die ("Erro ao conectar-se com o Banco de Dados"); mysql_select_db("nome do banco_de_dados"); $sql = mysql_query("INSERT INTO nome_da_tabela (nome_do_campo{no caso pode ser nota}) values ('$nota')"); mysql_query($sql); echo $nota; ?> Banco de Dados que você pode usar: CREATE TABLE `nome_da_tabela` ( `nota(ou coloque outro nome aqui e mude tbm na linha $sql)` varchar(2) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; Depois basta dar um mysql_query pra listar o resultado. Se você não souber como fazer, posta ai que eu te ajudo. Até Mais! OBS.: Testei o código e funcionou legal. Compartilhar este post Link para o post Compartilhar em outros sites