search

Home  >  Q&A  >  body text

Big help! ! PHP array as query database problem! !

<?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! ! !



奥立奥奥立奥2367 days ago1228

reply all(7)I'll reply

  • Summer

    Summer2018-07-10 14:50:57

    foreach can be written like this

    foreach($row5 as $vo){

    echo $vo;

    }

    reply
    0
  • 无忌哥哥

    无忌哥哥2018-07-07 14:29:14

    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
    0
  • 奥立奥

    Is it possible to use a foreach loop? How to write more efficiently?

    奥立奥 · 2018-07-07 14:32:12
    无忌哥哥

    There are only five elements, so there is no difference in efficiency.

    无忌哥哥 · 2018-07-07 15:06:00
    无忌哥哥

    There are only five elements, so there is no difference in efficiency.

    无忌哥哥 · 2018-07-07 15:06:01
    无忌哥哥

    $row['$i']['field name']

    无忌哥哥 · 2018-07-07 15:34:09
    奥立奥

    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)

    奥立奥 · 2018-07-07 15:34:35
    奥立奥

    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?

    奥立奥 · 2018-07-07 15:17:20
    奥立奥

    Fill in this loop body condition?

    奥立奥 · 2018-07-07 18:55:27
  • Cancelreply