如何使用变量选择字段。我想在基础栏(Seriennummer,MacAdresse)中选择字段(Seriennummer)。
我需要选择meta_key列和meta_value,其中变量$ result等于meta_key。
感谢大家的帮助。
我总是收到错误
捕获致命错误:无法将类stdClass的对象转换为\ wp-content \ plugins \ woocommerce \ templates \ checkout \ thankyou.php中的字符串
$result = wpuef_get_field('c2');
$value=$result->value;
echo $value,"<br>";
//Sql
$link = mysqli_connect("localhost", "root", "", "paymentdb");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt select query execution
$sql = "SELECT Seriennummer, MacAdresse FROM set_top_box WHERE Seriennummer ='".$result."'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>Seriennummer</th>";
echo "<th>MacAdresse</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['Seriennummer'] . "</td>";
echo "<td>" . $row['MacAdresse'] . "</td>";
echo "</tr>";
}
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
&#13;
答案 0 :(得分:0)
这是结果
$result = wpuef_get_field('c2');
$value=$result->value;
echo $value,"<br>";
//Sql
$link = mysqli_connect("localhost", "root", "", "paymentdb");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt select query execution
$sql = "SELECT Seriennummer, MacAdresse FROM set_top_box WHERE Seriennummer ='".$value=$result->value."'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>Seriennummer</th>";
echo "<th>MacAdresse</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['Seriennummer'] . "</td>";
echo "<td>" . $row['MacAdresse'] . "</td>";
echo "</tr>";
}
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
&#13;