无法从mysql接收数据

时间:2014-12-12 19:14:30

标签: php mysql

我试图从数据库中获取数据并将其存储在下面创建的表中。事情是没有错误消息,没有,但表中没有数据,但它创建了所需的页面数量 - 5(每页20个记录 - 在db中总共100个记录)

这里是我们页面的代码:

<?php 
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "payment";

$connection = new mysqli($servername, $username, $password, $dbname);


if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
$start_from = ($page-1) * 20; 
$sql = "SELECT * FROM banks ORDER BY BankName ASC LIMIT $start_from, 20"; 
$rs_result = mysqli_query ($connection,$sql); 

?> 
<table>
<tr><td>BankName</td><td>BIC</td></tr>
<?php 

while ($row = mysqli_fetch_assoc($rs_result)) { 
?> 
            <tr>
            <td><? echo $row["BankName"]; ?></td>
            <td><? echo $row["BIC"]; ?></td>
            </tr>
<?php 
}; 
?> 
</table>
<?php 
$sql = "SELECT COUNT(BankName) FROM banks"; 
$rs_result = mysqli_query($connection,$sql); 
$row = mysqli_fetch_row($rs_result); 
$total_records = $row[0]; 
$total_pages = ceil($total_records / 20); 

for ($i=1; $i<=$total_pages; $i++) { 
            echo "<a href='pagination.php?page=".$i."'>".$i."</a> "; 
}; 
?>

数据库名称:付款

这是我如何填补表格&#39;银行&#39;在mysql中

DROP TABLE `banks`;

CREATE TABLE `banks` (
  `id` mediumint(8) unsigned NOT NULL auto_increment,
  `BankName` varchar(255),
  `BIC` varchar(34),
  PRIMARY KEY (`id`)
) AUTO_INCREMENT=1;

INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Nunc Foundation","HR2868074439590957174"),("Facilisis Associates","SK0278253947289821060238"),("Nulla Interdum Ltd","GR6792877438540758859042158"),("Elit Incorporated","GE15735771537664806694"),("Dui Quis Associates","GI29YOQP779533388384588"),("Odio Aliquam PC","NL04OZOU3039063287"),("Phasellus PC","PS232950361277393433941384172"),("Ante Ipsum Primis LLC","SK6576014828156215265651"),("Sit Amet Risus Corporation","LB38063610008389984423100128"),("Blandit Inc.","CY80746861913710184665395083");
INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Sapien Nunc Pulvinar Ltd","SE2971469243490215982093"),("Ornare Lectus Justo LLP","PL04638376752565340430115585"),("Eget Consulting","TN2203449817294411776216"),("Diam Dictum PC","SA0707339167762038822862"),("Dolor Tempus Non Institute","AE413237966954343349062"),("Ante Dictum Mi Inc.","SK7166947243639919063650"),("Lorem Ipsum Dolor Corporation","FI0793624922259040"),("Nullam LLC","VG7722649424371381650317"),("Parturient Corporation","SI89446403148884983"),("Orci Corp.","MC8417829370027757931991297");
INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Ornare Elit Limited","SA3794349239336056649636"),("Nec Institute","AL16499908594511947809642456"),("Auctor Vitae Aliquet Industries","BE97624329404948"),("Proin Vel Consulting","BH73925713986691312360"),("Orci Luctus Et Corporation","DE74563454960683615381"),("Vulputate Nisi LLC","FO3841294839306423"),("Cras Dolor Dolor Foundation","MT78TDWK56103968997690681409041"),("Nec Limited","BG34VSPS18606219365462"),("Nascetur Ridiculus Ltd","CH8256879851538277551"),("Pede Cum Sociis Corp.","FR5277852656716780118772565");
INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Natoque Penatibus Et PC","BG53AGZP80112721620960"),("Massa Industries","TR582370730215466139565404"),("Donec Limited","BH86705863883792198319"),("Dolor Dolor Institute","DO41796182874282136425851874"),("Sed Libero Proin Associates","CZ5411603519354854012172"),("Consectetuer Cursus Institute","SA3184047665757824177582"),("Dui Semper Et LLC","NL91VMBI3977008594"),("Lacinia LLP","CR6896228497885899082"),("Porta Elit A Foundation","GR5905344924195307758295312"),("Fusce Associates","AD7977722536140145017680");
INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Nulla Tempor Augue Foundation","DE65842738582539893424"),("Ad Foundation","GB60XIUC88981754591606"),("Laoreet Ipsum Curabitur Incorporated","LU539065698460546129"),("Cras Dictum Ultricies Corp.","SM6752544071539931191353953"),("Nunc Ullamcorper Velit Incorporated","DE76080473329855489301"),("Ipsum Sodales Purus Limited","BA954011780879831971"),("Et Netus Et LLP","IS085559348212680415330861"),("Dui In Associates","LT564586849048032564"),("Ante Ipsum Primis LLP","SK9824408860482038199915"),("Risus Industries","PS664485582535919690570942945");
INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Rutrum Magna Limited","CR9321843951273249605"),("Eu Nulla At Inc.","DO48619462962071699774338871"),("Tellus Suspendisse Sed PC","LI6204702401609334146"),("Dictum PC","TN9008114906982737846777"),("Velit Pellentesque Corp.","EE737555749626602016"),("Libero Limited","IL392571168065366224090"),("Sociosqu Ad Litora Company","ES9590160897942494878405"),("Magna A Corp.","TR537609348459617242769090"),("Pharetra Incorporated","LI1808297118360563316"),("Molestie Ltd","MC9601753980466785599555790");
INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Libero Ltd","DO82021067207344015669482920"),("Semper Nam PC","SI92793706437319272"),("Integer Institute","LV82QQBD1054709923536"),("Vivamus LLC","VG8944759754489411018240"),("Vehicula Et Rutrum Incorporated","SI80868635844884022"),("Pharetra Associates","AZ76113716936626872246750053"),("Quis Pede Incorporated","GB33FGDO40967883066200"),("Ante Bibendum Ltd","GR5185826383729198623524298"),("Tellus Corporation","NL52MRNL5251926499"),("Convallis Corp.","PL49420145762522619699045558");
INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Sapien Nunc Pulvinar Inc.","IL308802410077318513675"),("In Scelerisque Scelerisque Consulting","LV50WHTT7181212076272"),("Ultrices Posuere Cubilia Associates","DK1091333316062458"),("Egestas Company","EE416144892810010696"),("Ante Ipsum Corp.","LT364460001520096925"),("Pede Company","SE6015937436784398888007"),("Sit Corp.","CY77400176876670744746317088"),("Est Mauris Rhoncus Ltd","ES1537073801276806247703"),("Ultrices Institute","RS94954893914518951727"),("Aliquet Ltd","VG3870364935077945164645");
INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Mauris Nulla LLP","HR5788737956002876474"),("Sit Corporation","BA886525148146712853"),("Nibh Corp.","DE45083668748813483643"),("Vestibulum Ante Institute","DK7150636773062012"),("Risus Quisque Libero Limited","FI8975360634570193"),("Mauris Ut Mi Limited","AZ35021498421240745001948476"),("Erat Associates","LU277349014781574915"),("Dolor Fusce Associates","CR1843988368670463569"),("Blandit Mattis Institute","KW5767276123220327583618914092"),("Eleifend Foundation","GR3906926203690693725383136");
INSERT INTO `Banks` (`BankName`,`BIC`) VALUES ("Vitae Nibh Donec Foundation","MT68VXWJ12775969006616753818202"),("Purus Consulting","SE3354867158473636995460"),("Nunc Incorporated","GI09XEOV082956245073393"),("Pharetra Corp.","LI5077767808089497585"),("Risus Duis A LLP","AT113922582132232306"),("Mauris Integer Sem Corporation","PT83909259409929644376456"),("Aliquam Eros Corp.","NO5699213466185"),("Egestas Lacinia Inc.","AL46878775148957642126532965"),("Amet Corp.","AZ50530093884918356223430348"),("Semper Consulting","AE898696147921384132256");

所以,我不明白为什么我在页面中创建了0个信息,它也给了我0个错误。

3 个答案:

答案 0 :(得分:0)

更正您的代码在表格中添加php标记。

            <tr>
            <td><?php echo $row["BankName"]; ?></td>
            <td><?php echo $row["BIC"]; ?></td>
            </tr>

答案 1 :(得分:0)

尝试替换

while ($row = mysqli_fetch_assoc($rs_result))

while ($row = $rs_result->fetch_assoc()) {

<? echo

<?=   

<?php echo 

答案 2 :(得分:-1)

只需在脚本开头添加调试代码:

的error_reporting(-1); ini_set('display_errors',1);

查看显示的错误。