javascript - How to get data from a html row (in a table) with php -


im trying information inside dynamic table when clicks on it, can read column column , extract data, show in textbox. dont know how since im new languages, hope can help. im doing @ moment exctrating data database , creating dynamic table it. i´ve tried couple things, none of them worked i´m not going paste failed attempts here. code (since lot of people had problems being mysql updated mysqli_:

    if (($result)||(mysqli_errno == 0)) {  echo "<table cellspacing='0' cellpadding='0' border='0' width='126%'>  <tr>   <td>    </table>  <div style='width:450; height:350px; overflow:auto;'>  <table cellspacing='0' cellpadding='1' border='1' width='380px'>    <tr style='color:white;background-colorgrey'>";  if (mysqli_num_rows($result)>0)  {       //loop thru field names print correct headers       $i = 0;       while ($i < mysqli_num_fields($result))       {           $fetch = mysqli_fetch_field_direct($result, $i);           echo "<th>". $fetch->name . "</th>";           $i++;   }  //display data  while ($rows = mysqli_fetch_assoc($result))  {   echo "<tr>";   foreach ($rows $data)   {     echo "<td align='center' width='400px'>". $data . "</td>";   }   echo"</tr>"; }  }else{    echo "<tr><td colspan='" . ($i+1) . "'>no results found!</td></tr>";  }    echo "</table></div>";                 

for interested in answer, figured out (the variable "id" stores element column "0" can change 0 different columns):

        <table cellspacing='0' cellpadding='0' border='0' width='126%'>   <tr>   <td>    </table>  <div style='width:450; height:350px; overflow:auto;'>  <table style="display: table-row" class='prueba' cellspacing='0'              cellpadding='1' border='1' width='380px'>     <tbody>     <tr style='color:white;background-colorgrey'>     <?php     ///******///   ///conection , query info go here///   ///******///    if (($result)||(mysqli_errno == 0))  {    if (mysqli_num_rows($result)>0)   {       //loop thru field names print correct headers       $i = 0;       echo "<th><a>check</a></th>";       while ($i < mysqli_num_fields($result))       {           $fetch = mysqli_fetch_field_direct($result, $i);    echo "<th><a>". $fetch->name . "</a></th>";    $i++;   }    //display data    while ($rows = mysqli_fetch_assoc($result))    {    echo "<tr onclick='content(this)'>";    foreach ($rows $data)    {     echo "<td align='center' width='400px'><a>". $data . "</a></td>";   }   echo"</tr>";   }   }/*else{    echo "<tr><td colspan='" . ($i+1) . "'>no results found!</td></tr>";      }*/    }else{    echo "'error in running query :'. mysqli_error()";    }        //echo "<style>";   /*echo "</tr></table></td></tr><tr><td>       <table min-width='400px' cellspacing='0' cellpadding='1'       border='1'>";*/   echo "</table></div>";  echo "<script>     function content(elem){         elem.style.backgroundcolor = 'red';          var id = $(elem).find('td:eq(0)').text();         alert(id);}         </script>";   ?>   </p> 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -