以编程方式从PHP重定向到新的页面(新选项卡)


Redirect to new PAGES from PHP programmatically (New tabs)

我需要从PHP重定向到新的选项卡Windows,对于记录集中的每个值。基本上,我需要点击具有特定值的URL,以便将数据发布到thinkSpeak网站。只要我的表有记录,我就需要动态构建新的重定向。

<?php
$conc = mysql_connect("localhost","root","xxxxxxx");
if (!$conc) die("couldn't connect"  );
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $con);
$re = mysql_query('SHOW VARIABLES LIKE "%character_set%";')or die(mysql_error());
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8");
$db_select = mysql_select_db("cccccc",$conc);

?>
<!-- STR_TO_DATE(asfaleia,'%m/%d/%Y')>'$curDate' AND -->
<!-- widget STARTS -->
<?php 
    $sql="SELECT  todo  FROM todo order by dleft asc";
    if ( !$data1 = mysql_query( $sql ) ) die( 'Could not SELECT, ' . mysql_error() );

    ?>
  <div style="float:right;">
    echo "<script type='"text/javascript'">"

    <?php while($row1 = mysql_fetch_assoc($data1)) {
        ?>
    echo "  window.open('https://api.thingspeak.com/update?api_key=xxxxxxxxxxx&field1=" <?php .$row1['todo']. ?>."', '_blank')"
        <?php
    }
    $conc->close();
    ?>
  echo "  </script>";

</div>

这给我一个错误

不幸的是,无法使用

PHP重定向打开新窗口。 打开新标签是 PHP 无法访问的浏览器功能。

我知道

这就是为什么我试图用JavaScript来做到这一点其实我做到了,

$sql="SELECT  todo  FROM todo where dleft < 5 order by dleft asc";
if ( !$data1 = mysql_query( $sql ) ) die( 'Could not SELECT, ' . mysql_error() );
    echo "<span> ".$row1['todo']."  </span><br>";
 echo "<script>";
 echo "function sleep(ms) {";
  echo "  var unixtime_ms = new Date().getTime();";
  echo "  while(new Date().getTime() < unixtime_ms + ms) {}}";
  while($row1 = mysql_fetch_assoc($data1)) {
        $gamertag = strtolower($row1['todo']);
        $url = "https://api.thingspeak.com/update?api_key=xxxxxxxxxx&field1=".$gamertag.".";
        echo "window.open('$url');".PHP_EOL;
        echo "sleep(50);";
    }
 echo "</script>";
?>

现在的问题是ThinkSpeak没有更新所有内容,必须有延迟