hi using following php code I am trying to populate a dropbox from mysql database:
enter code here
<?php
$mysqli = new mysqli('localhost', 'root', '', 'testdb');
if (mysqli_connect_errno())
{
die('Unable to connect!');
}
else
{
$query = 'SELECT * FROM language';
if ($result = $mysqli->query($query))
{
if ($result->num_rows > 0)
{
?>
<p> Select a language
<select id="selectLanguage">
<option value="">select</option>
<?php
while($row = $result->fetch_assoc())
{
?>
<option value='<?php echo $row[0]; ?>'><?php echo $row[1]; ?></option>
<?php
}
?>
</select>
</p>
<p id="result"></p>
<?php
}
else
{
echo 'No records found!';
}
$result->close();
}
else
{
echo 'Error in query: $query. '.$mysqli->error;
}
}
$mysqli->close();
?>
I am not getting any error but the dropbox populated by this message instead of cell values stored in database: (!) Notice : Undefined offset:0 in C:\wamp\test\index.ph on line 40 Call Stack#TimeMemoryFunctionLocation 10.0009684656{main}()...\index.php:0'> can you please let me know why this is happening?