php - can't fetch messages with its commets in chart system -


the following code fetching messages (status) comments mysql database tables chart , comments. problem code dieing when it's returning messages database causing comment field , messages not appear in html page because msg_id didn't match in table commets.

can me solve this? or better way can this?

sample code note: first have form using create messages bellow code fetch messages commented , return comments bellow message has been commented.

<?php //myqsl query select 2 tables chart , comments //this query not returning because script dieing on ch.msg_id=co.comment_id, cant find co.comment_id because has not yet created. $result = mysqli_query($con, "select ch.msg , ch.msg_id , co.comment , co.comment_id                                  chart ch                                  join comments co                                  on ch.msg_id=co.comment_id                                  order ch.msg_id, co.comment_id"); $last_msg = null;    while($row = mysqli_fetch_array($result))    {    if ($row['msg_id'] !== $last_msg) {      if ($last_msg !== null) {        echo "<table>";      }      echo "<table border='1' width='600px'>            <tr>            <td>            $row[msg]            </td>            </tr>\n";      $last_msg = $row['msg_id'];    }    //all comments should appear here if comment_id match msg_id in comments table    echo("    <tr>    <td>     $row[comment]    <p></p>     //html form insert comments table comments    //this form should appear below each message since comment field    <form action='drop_comment.php' method='post'>    <input type='text' name='comment' placeholder='drop comment...' value='' class='add_hook'>    <input name='comment_id' type='hidden'  value='$row[msg_id]'>    </form>    </td>    </tr>    ");    echo "</table>";    }    ?> 

why comment id message id?

i might wrong shouldn't comment record have column such commentmessageid?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -