Hello to all,
I’m trying to make a subselect in a report pdf but the result is “Null”
Can anyone tell me where did I go wrong?
here is the code:
$curent_id = {id};
//sub_db = ex
function fetch_ex()
{
$output = '';
$con = mysqli_connect("*****************","*****************","*****************","*****************") or die("Some error occurred during connection " . mysqli_error($con));
// Write query
$strSQL = "SELECT
_mr.id,
_ex.id_mr,
_ex.pos,
_ex.com,
_ex.date_f,
_ex.date_t,
_ex.exp
FROM
_mr INNER JOIN _ex ON _ex.id_mr = _mr.id
WHERE _ex.id_mr = '".$curent_id."'";
var_dump($strSQL);
// Execute the query.
$query = mysqli_query($con, $strSQL);
if ($query->num_rows > 0)
{
while($row = mysqli_fetch_array($query))
{
$output .= '<tr>
<td style="width:20%; text-align: left;">'.date("M.Y -", strtotime($row["date_f"])).'<br>'.date("M.Y", strtotime($row["date_t"])).'</td>
</tr>';
}
return $output;
}
}
var_dump($query);
$exp = fetch_exp();
//Close the connection
mysqli_close($con);
This select returns at var_dump($query);
NULL string(312) “SELECT _mr.id, _ex.id_mr, _ex.pos, _ex.com, _ex.date_f, _ex.date_t, _ex.exp FROM _mr INNER JOIN _ex ON _ex.id_mr = _mr.id WHERE _ex.id_mr = ‘’”
Observations:
- If I use instead of this parameter $curent_id a number (from the id list) everything works great;
- if I make this parameter $curent_id = with a number I have the same error >> NULL string(312) “SELECT _mr.id, _ex.id_mr, _ex.pos, _ex.com, _ex.date_f, _ex.date_t, _ex.exp FROM _mr INNER JOIN _ex ON _ex.id_mr = _mr.id WHERE _ex.id_mr = ‘’” <<
Does have anyone any ideas?
Thank you for your help,
Dan