html - {PHP,PDO} Unable to show/refresh table on button press -


i trying make page table management purposes. tried test if can call table show press of button,
if can achieve that, maybe can use way "refresh" table after user finishes changes data.
however, i'm can't code work. expect page function.

where i'm stuck

what i'm hoping it'll do

these codes: alter_db.php

    <html> <head> <meta charset="utf-8"> <title>alterdata</title> </head> <script type="text/javascript">     $(document).ready(function(){       refreshtable();     });      function refreshtable(){         $('div#test_table_go').load('showthetable.php', 'update=true').scrolltop(lastscrollpos);         }, 3000);     } </script> <body>  welcome!<br />  connecting :<?php echo $_post["dbname"]; ?><br> <?php   $db=$_post["dbname"];  $table=$_post["table"];  $spl_to_table="select * $db.$table;";  try {         $dbh = new pdo(                         "mysql:host=localhost",                          "root",                          "123"                         );         } catch (pdoexception $e) {         die("db error: ". $e->getmessage());         echo "connection: failed";     }     echo "connection: success <br> connecting table:".$table,"<br><br>";  echo '<form action="" method="post"><input type="button" value="show table" name="gotable"></form>';  switch ($table){     case 'test_table':         echo '<div id="test_table_go"></div>';         break; }     if(isset($_post['gotable'])) {    echo('gogo');     refreshtable(); }      ?> </body> </html> 

showthetable.php

<?php $db='testdb';  $table='test_table';  $spl_to_table="select * $db.$table;"; try {         $dbh = new pdo(                         "mysql:host=localhost",                          "root",                          "123"                         );         } catch (pdoexception $e) {         die("db error: ". $e->getmessage());         echo "connection: failed";     } $result = $dbh->query($spl_to_table); $q = $dbh->query("describe $db.$table");  $q -> execute(); $table_fields = $q->fetchall(pdo::fetch_column); $sth = $dbh->query($spl_to_table); $count = $sth->columncount(); echo '<br><hr>  <table border="1" style="width:100%" >';   foreach ($table_fields $value){         echo '<th>'.$value,'</th>';      }   while ($row = $result->fetch(pdo::fetch_num)) {     $i=0;     echo '<tr>';      while ($i<=($count-1)){     echo '<td><center>'.$row[$i],'</center></td>';     $i=$i+1;     }  } echo '</table>';    ?> 


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -