我有一个非常奇怪的问题,我从数据库中获取数据,如果有6个或更多条目,那么它有点开始显示错误的信息。由于某种原因,第6行或更多行的数据会将transaction_id显示为0,但它实际上在数据库中。在执行echo $key
之后,它甚至会在数组中显示它。
//修改
解决了,还有一个问题
好像我能够使用===
解决问题,但现在的问题是如何使用同样的东西才是数据库查询?因为我有一行所有transactions
transaction_id
= 0,但它以某种方式获得第6次交易。
这是我的代码:
<? foreach($transactions as $key): ?>
<tr>
<th><?=$key['id']?></th>
<th><?=$key['type']?></th>
<th><?=$key['amount']?></th>
<th><?php if($key['transaction_id'] == 0){echo 'Transaction not completed'; } else { echo $key['transaction_id'];}?></th>
<th><?=$key['user']?></th>
<th><?=date('Y-m-d H:i:s', $key['time']);?></th>
</tr>
<? endforeach; ?>
来自$transactions
Array
(
[0] => Array
(
[id] => 1
[0] => 1
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 80681
[3] => 80681
[transaction_id] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[4] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[time] => 1492790068
[5] => 1492790068
[user] => name
[6] => name
)
[1] => Array
(
[id] => 2
[0] => 2
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81085
[3] => 81085
[transaction_id] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[4] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[time] => 1492856512
[5] => 1492856512
[user] => name
[6] => name
)
[2] => Array
(
[id] => 3
[0] => 3
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81212
[3] => 81212
[transaction_id] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[4] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[time] => 1492857095
[5] => 1492857095
[user] => name
[6] => name
)
[3] => Array
(
[id] => 4
[0] => 4
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 81053
[3] => 81053
[transaction_id] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[4] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[time] => 1492858665
[5] => 1492858665
[user] => name
[6] => name
)
[4] => Array
(
[id] => 5
[0] => 5
[type] => withdraw
[1] => withdraw
[address] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[2] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[amount] => 20000
[3] => 20000
[transaction_id] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[4] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[time] => 1492865145
[5] => 1492865145
[user] => name
[6] => name
)
[5] => Array
(
[id] => 6
[0] => 6
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 120888
[3] => 120888
[transaction_id] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[4] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[time] => 1492942795
[5] => 1492942795
[user] => name
[6] => name
)
)
Array
(
[0] => Array
(
[id] => 1
[0] => 1
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 80681
[3] => 80681
[transaction_id] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[4] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[time] => 1492790068
[5] => 1492790068
[user] => name
[6] => name
)
[1] => Array
(
[id] => 2
[0] => 2
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81085
[3] => 81085
[transaction_id] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[4] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[time] => 1492856512
[5] => 1492856512
[user] => name
[6] => name
)
[2] => Array
(
[id] => 3
[0] => 3
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81212
[3] => 81212
[transaction_id] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[4] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[time] => 1492857095
[5] => 1492857095
[user] => name
[6] => name
)
[3] => Array
(
[id] => 4
[0] => 4
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 81053
[3] => 81053
[transaction_id] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[4] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[time] => 1492858665
[5] => 1492858665
[user] => name
[6] => name
)
[4] => Array
(
[id] => 5
[0] => 5
[type] => withdraw
[1] => withdraw
[address] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[2] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[amount] => 20000
[3] => 20000
[transaction_id] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[4] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[time] => 1492865145
[5] => 1492865145
[user] => name
[6] => name
)
[5] => Array
(
[id] => 6
[0] => 6
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 120888
[3] => 120888
[transaction_id] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[4] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[time] => 1492942795
[5] => 1492942795
[user] => name
[6] => name
)
)
Array
(
[0] => Array
(
[id] => 1
[0] => 1
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 80681
[3] => 80681
[transaction_id] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[4] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[time] => 1492790068
[5] => 1492790068
[user] => name
[6] => name
)
[1] => Array
(
[id] => 2
[0] => 2
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81085
[3] => 81085
[transaction_id] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[4] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[time] => 1492856512
[5] => 1492856512
[user] => name
[6] => name
)
[2] => Array
(
[id] => 3
[0] => 3
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81212
[3] => 81212
[transaction_id] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[4] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[time] => 1492857095
[5] => 1492857095
[user] => name
[6] => name
)
[3] => Array
(
[id] => 4
[0] => 4
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 81053
[3] => 81053
[transaction_id] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[4] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[time] => 1492858665
[5] => 1492858665
[user] => name
[6] => name
)
[4] => Array
(
[id] => 5
[0] => 5
[type] => withdraw
[1] => withdraw
[address] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[2] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[amount] => 20000
[3] => 20000
[transaction_id] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[4] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[time] => 1492865145
[5] => 1492865145
[user] => name
[6] => name
)
[5] => Array
(
[id] => 6
[0] => 6
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 120888
[3] => 120888
[transaction_id] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[4] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[time] => 1492942795
[5] => 1492942795
[user] => name
[6] => name
)
)
Array
(
[0] => Array
(
[id] => 1
[0] => 1
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 80681
[3] => 80681
[transaction_id] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[4] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[time] => 1492790068
[5] => 1492790068
[user] => name
[6] => name
)
[1] => Array
(
[id] => 2
[0] => 2
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81085
[3] => 81085
[transaction_id] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[4] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[time] => 1492856512
[5] => 1492856512
[user] => name
[6] => name
)
[2] => Array
(
[id] => 3
[0] => 3
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81212
[3] => 81212
[transaction_id] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[4] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[time] => 1492857095
[5] => 1492857095
[user] => name
[6] => name
)
[3] => Array
(
[id] => 4
[0] => 4
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 81053
[3] => 81053
[transaction_id] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[4] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[time] => 1492858665
[5] => 1492858665
[user] => name
[6] => name
)
[4] => Array
(
[id] => 5
[0] => 5
[type] => withdraw
[1] => withdraw
[address] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[2] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[amount] => 20000
[3] => 20000
[transaction_id] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[4] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[time] => 1492865145
[5] => 1492865145
[user] => name
[6] => name
)
[5] => Array
(
[id] => 6
[0] => 6
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 120888
[3] => 120888
[transaction_id] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[4] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[time] => 1492942795
[5] => 1492942795
[user] => name
[6] => name
)
)
Array
(
[0] => Array
(
[id] => 1
[0] => 1
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 80681
[3] => 80681
[transaction_id] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[4] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[time] => 1492790068
[5] => 1492790068
[user] => name
[6] => name
)
[1] => Array
(
[id] => 2
[0] => 2
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81085
[3] => 81085
[transaction_id] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[4] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[time] => 1492856512
[5] => 1492856512
[user] => name
[6] => name
)
[2] => Array
(
[id] => 3
[0] => 3
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81212
[3] => 81212
[transaction_id] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[4] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[time] => 1492857095
[5] => 1492857095
[user] => name
[6] => name
)
[3] => Array
(
[id] => 4
[0] => 4
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 81053
[3] => 81053
[transaction_id] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[4] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[time] => 1492858665
[5] => 1492858665
[user] => name
[6] => name
)
[4] => Array
(
[id] => 5
[0] => 5
[type] => withdraw
[1] => withdraw
[address] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[2] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[amount] => 20000
[3] => 20000
[transaction_id] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[4] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[time] => 1492865145
[5] => 1492865145
[user] => name
[6] => name
)
[5] => Array
(
[id] => 6
[0] => 6
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 120888
[3] => 120888
[transaction_id] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[4] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[time] => 1492942795
[5] => 1492942795
[user] => name
[6] => name
)
)
Array
(
[0] => Array
(
[id] => 1
[0] => 1
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 80681
[3] => 80681
[transaction_id] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[4] => 748d167d779892468f00b1f846bf6c296d69335ae3fd4b17510a506ed82cffac
[time] => 1492790068
[5] => 1492790068
[user] => name
[6] => name
)
[1] => Array
(
[id] => 2
[0] => 2
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81085
[3] => 81085
[transaction_id] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[4] => 207604fd8c7e9d2d6a8d80a24f34ab1cd9e5a3de44aa3efbaacf186d89d7f3d9
[time] => 1492856512
[5] => 1492856512
[user] => name
[6] => name
)
[2] => Array
(
[id] => 3
[0] => 3
[type] => deposit
[1] => deposit
[address] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[2] => 1LoVYNdVfJPGuA6DKQEeHhMM9ivRjdZkKh
[amount] => 81212
[3] => 81212
[transaction_id] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[4] => 483b537623961ab68e04f41bf2a7e56aa4eb7a49cfc8d860d555d60fd6db3c2e
[time] => 1492857095
[5] => 1492857095
[user] => name
[6] => name
)
[3] => Array
(
[id] => 4
[0] => 4
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 81053
[3] => 81053
[transaction_id] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[4] => 42d7c459e6d15d69d59884284f0933c74915e3ec5a1ac7a40c19548daca3677a
[time] => 1492858665
[5] => 1492858665
[user] => name
[6] => name
)
[4] => Array
(
[id] => 5
[0] => 5
[type] => withdraw
[1] => withdraw
[address] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[2] => 1PQwKUHBTUzYB62pwyYXkNFD8SGxp4anAk
[amount] => 20000
[3] => 20000
[transaction_id] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[4] => 9d6429d71d2dbd7658d36dd72c1b4aef761949cd393a18fd360edc875d8602c7
[time] => 1492865145
[5] => 1492865145
[user] => name
[6] => name
)
[5] => Array
(
[id] => 6
[0] => 6
[type] => deposit
[1] => deposit
[address] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[2] => 1531LxjQgH7AMXN1UptZYUEvP4puEyQixa
[amount] => 120888
[3] => 120888
[transaction_id] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[4] => db5e7bbaa8df754d6a16e4b42d48de6d8a476c70017ba8c550926e9eabb6875d
[time] => 1492942795
[5] => 1492942795
[user] => name
[6] => name
)
)
答案 0 :(得分:0)
试试这个
Object.keys
如果这不起作用,请print_r()显示您的数组内容
获取id = 0的查询:
$key->id
$key->type
....
你的$ transactions print_r()显示重复,如果它正确运行,请尝试检查事务查询