mysql - I am having issues with parsing a variable from an SQL into another SQL statement with PHP -


<?php   if(isset($_post['submitted'])){  //connecting database  include('includes/connection.php');      // creating variables post selected input item database $meeting_type = explode('|', $_post['meeting_type']); $date_picker = $_post['date_picker'];  //$query = "select * meeting_tb meeting_type = '$meeting_type[1]'"; $query = "select meeting_id, meeting_type, date meeting_tb date in (select max(date) mindate meeting_tb meeting_type = '$meeting_type[1]')";        $query_result = mysqli_query($db_con, $query) or die("error retrieving data");      $row_meeting = mysqli_fetch_array($query_result, mysqli_assoc) or die("not able retrieve information");    $query_item = "select join_tb.item_id, item_name, item_description join_tb inner join meeting_item_tb on join_tb.item_id = meeting_item_tb.item_id join_tb.meeting_id = '$row_meeting[meeting_id]'";  $result = mysqli_query($db_con, $query_item) or die("error retrieving data");  echo "<table>"; echo "<tr> <th>item id</th> <th>item name</th>  <th>item description</th> </tr>";  while ($row = mysqli_fetch_array($result, mysqli_assoc)){  echo "<tr><td>"; echo $row['item_id']; echo "</td><td>"; echo $row['item_name']; echo "</td><td>"; echo $row['item_description']; echo "</td></tr>";  }  echo "</table>";   }  //end of if statement   ?> 

the issue involves use of $row_meeting[meeting_id] in second select statement. if put numeric value in place of $row_meeting[meeting_id], select statement works , displays output on browser. if use $row_meeting[meeting_id] in second select statement, not data database

by putting single inverted commas around $row_meeting[meeting_id], converting number string when parsing sql. avoid parsing string can remove single inverted commas. select statement like:

$query_item = "select join_tb.item_id, item_name, item_description join_tb inner join meeting_item_tb on join_tb.item_id = meeting_item_tb.item_id join_tb.meeting_id = $row_meeting['meeting_id']"; 

hope helps.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -