View mysql data using PHP/Jquery with confirmation dialog box -


i have question jquery ui dialog box , showing dynamic content database. here have table generating blog post using php , mysql , in table, there column view contents belong each blog post.

that link -

$html .= "  <td align='center'>\n"; $html .= "      <a href='#' id='blog-$blog_id' class='view' >\n"; $html .= "          <span class='icon-small ico-view-blog' title='view blog post'></span>\n"; $html .= "      </a>\n"; $html .= "  </td>\n"; 

clicking on above link need pop-up jquery dialog display blog content. eg: blog-title, author, image, blog etc.

i tried jquery , using separate php script fetch blog contents this. not pop-up dialog expect.

this jquery have used dialog:

$( "#dialog-view-blog" ).dialog({         autoopen: false,         height: 450,         width: 650,         modal: true,         buttons: {             cancel: function() {             $( ).dialog( "close" );             }         },          position: {              my: "center top",              at: "center top",             of: "#content"         }     }); 

this how send ajax request data php file update content in dialog -

$( "a.view" ).click(function(e) {     e.preventdefault();          var clickblogid = this.id.split('-'); //split string      var dbnumberid = clickedid[1]; //and number array     var blogid = 'blog_id='+ dbnumberid; //build post data structure       $.ajax({         url: 'update_blog.php',         type: 'post',         data: blogid,         success: function(data){              //alert(data);              //construct data however, update html of popup div              //$('#dialog-view-blog').html(data);             $('#dialog-view-blog').dialog('open');         }     });              });  

my code update_blog.php page

if (isset($_post['blog_id'])) {      //blog_id      $blogid = $_post['blog_id'];      // if there no blog user display string.      $q = "select * userblogs blog_id = ?";     // prepare statement:     $stmt = mysqli_prepare($dbc, $q);     // bind variables:     mysqli_stmt_bind_param($stmt, 'i', $blogid);                                 // execute query:     mysqli_stmt_execute($stmt);      //store result       mysqli_stmt_store_result($stmt);      // number of rows returned:      $rows = mysqli_stmt_num_rows ($stmt);      if ( $rows == 1 ) {          $viewblog  = "<div id='dialog-view-blog' title='view blogs'>\n";         $viewblog .= "      <h2>$blog_title</h2>\n";         $viewblog .= "  <p>$blog_author | $blog_added_date</p>\n";         $viewblog .= "  <p>";         $viewblog .= "          <img src='".upload_dir.$username."/".$blog_image."' alt='image blog title' />";         $viewblog .= "      $blog</p>";         $viewblog .= "</div>\n";                  echo $viewblog;     }  

can pointed me have gone wrong? comments appreciated.

thank you.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -