How do i go about this
i have been able to get this to work good but i still have something not working perfectly. I want to be able to query the database from the respective ID but its not working
this is the db query i use
<?php
require_once('inc/config.php');
$con = mysqli_connect($host, $user, $pass, $db) or die('Cannot Connect, Reason: '.mysqli_connect_error());
$sql = "select * from crime_db_table";
$result = $con->query($sql);
if($result->num_rows > 0){
while($row = $result-> fetch_assoc()){
$id = $row['id'];
$case_number = $row['case_number'];
}
}
mysqli_close($con);
?>
this retrieves the id and the case number and i want to use the case number retrieved from here and pass the data to another url. i am using a Javascript function for this like this
<script language="javascript" type="text/javascript">
function handleSelection(selectElement){
var selectedOption = selectElement.value;
if (selectedOption === 'modify') {
//window.location.href = 'ModifyReport.php';
window.open('ModifyReport.php?case_number=<?php echo $case_number;?>', '_blank');
}else if(selectedOption === 'delete'){
window.location.href = 'ModifyReport.php';
}
}
</script>
It passes, but it does not pass for the respective table
And here is the source code for the table
<?php
require_once('inc/config.php');
$con = mysqli_connect($host, $user, $pass, $db) or die ('Cannot Connect , Reason: '.mysqli_connect_error());
$sql = "select * from crime_db_table";
$result = $con->query($sql);
if($result->num_rows>0){
while($row = $result->fetch_assoc()){
$result_table = '<TR valign=top>
<TD width=127 align=center><div class=wpmd>
<div align=center><font size=2>'.$row['case_number'].'</font></div>
</div>
</TD>
<TD width=109 height=26 align=center><div class=wpmd>
<div align=center><font size=2>'.$row['crime_type'].'</font></div>
</div>
</TD>
<TD width=90 height=26 align=center><div class=wpmd>
<div align=center><font size=2>'.$row['fullname'].'</font></div>
</div>
</TD>
<TD width=122 height=26 align=center><div class=wpmd>
<div align=center><font size=2>'.$row['address'].'</font></div>
</div>
</TD>
<TD width=118 height=26 align=center><div class=wpmd>
<div align=center><font size=2>'.$row['telephone'].'</font></div>
</div>
</TD>
<TD width=157 height=26 align=center><div class=wpmd>
<div align=center><font size=2>'.$row['incident_date'].'</font></div>
</div>
</TD>
<TD width=103 height=26 align=center><div class=wpmd>
<div align=center><a href=http://google.com title=><font size=2>Image.jpg</font></a></div>
</div>
</TD>
<TD width=138 height=26 align=center><div class=wpmd>
<div align=center><font size=2>'.$row['crime_desc'].'</font></div>
</div>
</TD>
<TD width=138 height=26 align=center><font size=2><select name=dropdown id=dropdown onchange=handleSelection(this)><option>Please Select</option><option value=modify>Modify</option><option value=delete>Delete</option></select></font></TD>
</TR>';
echo $result_table;
}
}else{
echo "<div><font face=Verdana><B>No Results Found</B></font></div>";
}
$con->close();
?>
What could possibly be wrong?
How can i pass the data from the php code to ModifyReport.php?case_number=<?php echo $case_number;?>'
=
If I have 2 rows in my database or 3 for instance, when i click the dropdown, I have this URL
http://localhost/crimereport/reportsData.php?data=1
When i click the second, rather than change to 2, i still have it as thus http://localhost/crimereport/reportsData.php?data=1
Why?