Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function chapters( $atts, $content ) {
- $postid = get_post($my_id);
- $result_chaptertitle = mysql_query("SELECT * FROM ltd_chapters_titles WHERE chaptertitle='$content' AND postid='$postid'");
- $num_rows_chaptertitle = mysql_num_rows($result_chaptertitle);
- $result_chaptercount = mysql_query("SELECT * FROM ltd_chapters WHERE postid='$postid'");
- $num_rows_chaptercount = mysql_num_rows($result_chaptercount);
- if ($num_rows_chaptertitle == 0) {
- mysql_query("INSERT INTO ltd_chapters_titles (postid, chaptertitle) VALUES ('$postid','$content')");
- }
- if ($num_rows_chaptercount == 0) {
- mysql_query("INSERT INTO ltd_chapters (postid, chapter) VALUES ('$postid', 1)");
- } else {
- mysql_query("UPDATE ltd_chapters SET chapter=chapter+1 WHERE postid='$postid'");
- }
- $chaptercount = mysql_query("SELECT chapter FROM table WHERE postid='$postid'");
- mysql_query("UPDATE ltd_chapters SET count='$chaptercount' WHERE postid='$postid' AND chaptertitle='$content'");
- return '<div id="chapter'.$chaptercount.'"><h3>'.$content.'</h3></div>';
- }
- add_shortcode('chapter', 'chapters');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement