I am trying to get some information out of a query and into the values of some inputs, the parameter that it sends to display the specific information is a ID that is being send like this:
PHP on a includes file:
<a href="modificarLab.php?idlab='.$row['idlab'] .'">
<input type = "submit" value = "Modificar" class= "btnModificar" id = "btnModificar-'.$row['idlab'].'"
style="position:absolute;left:170px;top:192px;"/>
</a>
When I click the above link it sends me to another page that reflects the idlab on the URL, so it shows idlab= X, where x depends on the idlab of the button clicked, this part seems to be working just fine.
The problem comes when trying to get the information into the inputs'values, in a example I used as reference they used the exact same syntax (including the part above with the href)and it is working, so I don't know what could I be doing wrong. This is how my code looks:
On the page the href refers to:
UPDATED php:
<?php
isset($_POST['lab']) ? $_POST['lab'] : 'Unknown';
$result = getSpecificLabModify($_GET['lab']);
?>
<form id="frmLabs" method="post">
<?php
if (isset($_GET['idlab'])){
$result = getSpecificLabModify($_GET['idlab']);
}
?>
<label for="txtCapacidad">Capacidad</label>
<input type="text" name="txtCapacidad" id="txtCapacidad" value="<?php echo utf8_encode($result['capacidad'])?>">
<label for="txtNumLab">Código de laboratorio</label>
<input type="text" name="txtNumLab" id="txtNumLab" value="<?php echo utf8_encode($result['codigolab'])?>">
<label for="txtUbicacion">Ubicación</label>
<input type="text" name="txtUbicacion" id="txtUbicacion" value="<?php echo utf8_encode($result['ubicacion'])?>">
But instead of the values inside I am getting the error:
EDIT ERROR:
Notice: Undefined index: idlab in C:\wamp\www\Proyecto\modificarLab.php on line 66 Just in case the function to get the information is this one:
On the includes PHP file:
function getSpecificLabModify($pId){
$query = "SELECT * FROM labs WHERE idlab=$pId";
$result = do_query($query);
$row = mysql_fetch_assoc($result);
return $row;
}
I've tried a lot of things but so far nothing has yielded any results. Thanks in advance.
$_GET['idlab']is not setprint_r($_GET);at the top of the page and let me know what it says.