Advertisement
Guest User

helpplease

a guest
Jul 6th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. function chapters( $atts, $content ) {
  2.  
  3. $postid = get_post($my_id);
  4.  
  5. $result_chaptertitle = mysql_query("SELECT * FROM ltd_chapters_titles WHERE chaptertitle='$content' AND postid='$postid'");
  6. $num_rows_chaptertitle = mysql_num_rows($result_chaptertitle);
  7.  
  8. $result_chaptercount = mysql_query("SELECT * FROM ltd_chapters WHERE postid='$postid'");
  9. $num_rows_chaptercount = mysql_num_rows($result_chaptercount);
  10.  
  11. if ($num_rows_chaptertitle == 0) {
  12. mysql_query("INSERT INTO ltd_chapters_titles (postid, chaptertitle) VALUES ('$postid','$content')");
  13. }
  14.  
  15. if ($num_rows_chaptercount == 0) {
  16. mysql_query("INSERT INTO ltd_chapters (postid, chapter) VALUES ('$postid', 1)");
  17. }   else    {
  18. mysql_query("UPDATE ltd_chapters SET chapter=chapter+1 WHERE postid='$postid'");
  19. }
  20.  
  21. $chaptercount = mysql_query("SELECT chapter FROM table WHERE postid='$postid'");
  22. mysql_query("UPDATE ltd_chapters SET count='$chaptercount' WHERE postid='$postid' AND chaptertitle='$content'");
  23. return '<div id="chapter'.$chaptercount.'"><h3>'.$content.'</h3></div>';
  24.  
  25. }
  26.  
  27. add_shortcode('chapter', 'chapters');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement