Reputation: 71
I am receiving address from a search.php
and then send that value to map.php
. I can also get the id from given address.
My question is how can I save the value of $row['id']
as a variable?
<?php
if(isset($_GET['w1'])){
$id_1 = $_GET['w1'];
$conn = mysqli_connect('localhost',$username,$password,'marker');
$query = "SELECT * FROM markermap WHERE address= '".$id_1."'";
$result = mysqli_query($conn,$query) or die(mysqli_error($conn));
echo'<table class="responstable">';
if($result->num_rows > 0){
while($row = mysqli_fetch_assoc($result)){
echo '<tr>';
echo '<td>'. $row['id'].' </td>';
echo '</tr>';
}
} else {
echo "No record available";
}
} else {
echo 'No id is comming';
}
echo'</table>';
?>
Upvotes: 0
Views: 31
Reputation: 128
You mean something like this?
$row_id = $row['id'];
$row['id'] is already a variable so why do you want to assign it to another variable? And try to bind values from $_GET cause it's really not safe to put them straight into query. Maybe try PDO.
Upvotes: 1