我有一个充满名字的表,我有一个存储过程返回所有名称。然而,它没有做我期望它做的事情,即使使用日志我也无法查明问题。我没有得到实际名称的下拉列表,而是得到空白值的下拉,好像我可以实际选择一个值,但是console.log显示一个空值,我假设它意味着它是空的
connection.php
<?php
require 'credentials.php';
include '../ChromePhp.php';
$con = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($con->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
ChromePhp::warn('something went wrong!'); // didn't reach here
}
?>
这会调用retrieveAllPokemonNames.php
<?php
include '../database/retrieveAllPokemonNames.php';
while ($row = $result->fetch_assoc()){
echo "<option value= ".$row[0].">".$row[0]."</option>";
}
?>
retrieveAllPokemonNames.php
<?php
require 'connection.php';
$sql = "CALL sp_selectAllPokemonName";
if ($result = $con->query($sql)){
ChromePhp::log('query is successful'); // output
ChromePhp::log($result); // log outputs a Object { current_field: null, field_count: null, .....etc }
}
?>
当我在phpMyAdmin的界面中调用它时,SQL查询工作正常,sp_selectAllPokemonName
基本上是
Select * From PokemonName
返回~100行