如何正确插入fetch数组

时间:2015-03-18 12:25:57

标签: arrays fetch

如何在此代码中插入fetch数组。我没有得到胎儿。

$ctext = "SELECT tekst FROM members"; 

if (mysqli_query($conn, $ctext))
    {
        echo $ctext;
    }
    else
    {
    echo "erooroorror"; 
    }
    mysqli_close($conn);

2 个答案:

答案 0 :(得分:0)

$ctext = "SELECT tekst FROM members"; 

$result = mysqli_query($conn, $ctext);
if ($result) {
    while($row = mysqli_fetch_array($result)) {
        echo $row['tekst'] . '<br />';
    }
} else {
    echo "erooroorror"; 
}

答案 1 :(得分:0)

您可以通过执行批处理操作来插入它。请检查下面的代码,希望它能帮助您找到解决方案

  $QueryToMember = mysql_query("SELECT tekst FROM members");

 if ($QueryToMember) {
      while ($row = mysql_fetch_array($QueryToMember)) {
        $Array[] = "('" . $row['tekst'] . "')";
       }

       if (isset($Array) && count($Array) > 0) {

           $InsertString = implode(',', $Array);

    $Query = mysql_query("INSERT INTO test1 (tekst) VALUES " . $InsertString);
        }
    } 
    else {
       echo "erooroorror";
    }