I am starting to get furious here
mysql_query don't recognize my variable $d1 even I tried to rename it
here is the code..
html:
<form action ="manageVessel.php" method ="POST">
<select onchange ="this.form.submit();" class ="form-control" name ="ViewPositionCertificates">
<option>Choose a Position </option>
<?php
$ViewPCertificates = mysql_query("SELECT * FROM table_cmsjob") or die("error" . mysql_error());
while ($rwViewPCertificates = mysql_fetch_array($ViewPCertificates)) {
?>
<option value =" <?php echo $rwViewPCertificates['jobName']; ?> "> <?php echo $rwViewPCertificates['jobName']; ?></option>
<?php } ?>
</select>
</form>
php:
<?php if (isset($_POST['ViewPositionCertificates'])) { ?>
<table class = "table table-bordered">
<tr class ="bg-primary">
<td> List of Certificates </td>
</tr>
<?php
$d1 = $_POST['ViewPositionCertificates'];
echo $_POST['ViewPositionCertificates'];
$ViewCertificatesFP = mysql_query("SELECT * FROM table_cmsjobassigning WHERE jobName = '$d1' ") or die("error" . mysql_error());
while ($rwViewCertificatesFP = mysql_fetch_array($ViewCertificatesFP)) {
echo "<tr>";
echo "<td>" . $rwViewCertificatesFP['Certificate'] . "</td>";
echo "</tr>";
}
?>
</table>
<?php } ?>
MYSQL WHERE clause is working fine when I used a string for example
mysql_query("SELECT * FROM table_cmsjobassigning WHERE jobName = 'MASTER' ") or die("error" . mysql_error());
but when I used a variable to assign $_POST['ViewPositionCertificates'] to a variable MYSQL WHERE clause doesn't read it any help?
$ViewCertificatesFP = mysql_query("SELECT * FROM table_cmsjobassigning WHERE jobName = '{$d1}' ") or die("error" . mysql_error());use this query and a pair of avice, please prefer mysqli over mysqlmysql_*functions as they are deprecated and in the newly released PHP 7.0 deleted use mysqli or PDO instead. Also when handling user input use prepared statements otherwise your query is open for SQL injections