Big help! ! PHP array as query database problem! !
奥立奥
奥立奥 2018-07-07 14:06:46
0
7
1222

<?php

$dopage->GetPage("SELECT * FROM `#@__unameym` WHERE uname='$c_uname' ORDER BY id DESC");

if ($dosql->GetTotalRow() > 0)

?>

<?php

$row3=[];

while($row = $dosql->GetArray())

{

$row3 =array( $row['ypname']);

$row5 = array(end($row3));

?>

<?php

var_dump ($row5);




##//The output is



array(1) { [0]=> string(4) "a凯" } array(1) { [0]=> string(12) "不老 salty egg" } array (1) { [0]=> string(11) "vitamin B2" } array(1) { [0]=> string(9) "vitamin" } array(1) { [0]=> string (9) "Xiaocaihu" } , but how to loop through the elements in $row5 one by one?

}


?>

<?php

$dopage->GetPage("SELECT * FROM `#@__liuxiang` WHERE ypname='end($ row5)' ORDER BY id DESC",20);

if($dosql->GetTotalRow() > 0)

Output the data found in the table to the table! ! !



奥立奥
奥立奥

reply all(2)
Summer

foreach can be written like this

foreach($row5 as $vo){

echo $vo;

}

无忌哥哥

Use a for loop to obtain each value through the subscript method, i=0;i<count($row);i++, then loop through the query and merge it into an array.

  • reply Is it possible to use a foreach loop? How to write more efficiently?
    奥立奥 author 2018-07-07 14:32:12
  • reply There are only five elements, so there is no difference in efficiency.
    无忌哥哥 author 2018-07-07 15:06:00
  • reply There are only five elements, so there is no difference in efficiency.
    无忌哥哥 author 2018-07-07 15:06:01
  • reply $row['$i']['field name']
    无忌哥哥 author 2018-07-07 15:34:09
  • reply How to convert something like this? Array ( [0] => a medicine ) Array ([0] => a medicine [1] => not old salted egg) Array ([0] => a medicine [1] => Salted Egg [2] => Vitamin B2) Array ( [0] => a medicine [1] => Salted Egg [2] => Vitamin B2 [3] => Vitamin ) Array ( [0] => a medicine [1] => Salted Egg [2] => Vitamin B2 [3] => Vitamin [4] => Xiaocaihu)
    奥立奥 author 2018-07-07 15:34:35
  • reply The number of elements is variable, it may be more than 1,000, and the keys of $row5 are all 0. Why isn't it increasing?
    奥立奥 author 2018-07-07 15:17:20
  • reply Fill in this loop body condition?
    奥立奥 author 2018-07-07 18:55:27
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template