我试图弄清楚下面的 mysqli 代码有什么问题。数据肯定在表中。我有两个问题:
- 为什么这没有给我任何结果?
我可以将 echo
<table></table>
部分放在单独的 php 文件中吗,如果可以,我将如何调用$name,$partner,$cell
等?<?php $mysqli = new mysqli($host, $uname, $pword, $db); if ($mysqli->connect_errno) { echo "Connection failed: %s\n", $mysqli->connect_error; exit(); } $query = ("SELECT * FROM contacts WHERE contacttype IN ('Buyer','Seller','Buyer / Seller','Investor') AND leadstatus = 'New' ORDER BY date DESC"); $result = $mysqli->query($query); while ($row = $result->fetch_array()) { $space = (!empty($row['firstname']) && !empty($row['lastname'])) ? ' ' : ''; $name = $row['firstname'].$space.$row['lastname']; $partner = $row['spousefirst']; $cell = (!empty($row['phonecell'])) ? " {$row['phonecell']} (cell)" : ''; $email = (!empty($row['email'])) ? " {$row['email']} (email)" : ''; $ID = $row['ID']; echo'<table> <tbody> <tr> <td><input type="checkbox" name="" id="" value="<? echo $ID; ?>"></td> <td><a href="/backend/leads/view/?ID=<? echo $ID; ?> "><strong><? echo $name; ?></strong></a></td> <td><a href="/backend/leads/view/?ID=<? echo $ID; ?> "><? echo $partner; ?></a></td> <td><? echo $phonecell; ?></td> <td><a href="mailto:<? echo $email; ?>"><? echo $email; ?></a></td> <td><? echo date("M jS, g:i A", strtotime($date)); ?></td> <td><? echo $contacttype; ?></td> <td><? echo $agentassigned; ?></td> <td><? echo $leadstatus; ?></td> <td><a href="/backend/contacts/notes.php?ID=<? echo $ID; ?>">View </a>+ </td> <td><a href="/backend/contacts/todo.php?ID=<? echo $ID; ?>">View </a>+ </td> <td><a href="/backend/contacts/deletesuccess.php?ID=<? echo $ID; ?>">D</a></td> </tr> </tbody> </table>'; } ?>
编辑:
它显示<table>
但只是没有给我 $name、$email...ect 的值。