Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL查询的PHP问题。该函数仅针对第一个mysql结果运行_Php_Mysql_Loops - Fatal编程技术网

MySQL查询的PHP问题。该函数仅针对第一个mysql结果运行

MySQL查询的PHP问题。该函数仅针对第一个mysql结果运行,php,mysql,loops,Php,Mysql,Loops,我试图在网上搜索类似的东西,但没有结果。 我试图做的只是从数据库中获取结果,然后为每个结果运行一些函数。 我们有两种功能。 第一个函数是当行“Type”为=F时,第二个函数是当行“Type”为=T时。 我在这段代码中遇到的问题是,它只为第一个mySQL结果运行函数。 但是我同时有更多的结果,函数应该为每个mySQL结果运行,而不仅仅是第一个结果 我不知道我是不是需要一辆foreach什么的。我对数组和php循环一无所知 多谢各位 include_once("../dbconnection.php

我试图在网上搜索类似的东西,但没有结果。 我试图做的只是从数据库中获取结果,然后为每个结果运行一些函数。 我们有两种功能。 第一个函数是当行“Type”为=F时,第二个函数是当行“Type”为=T时。 我在这段代码中遇到的问题是,它只为第一个mySQL结果运行函数。 但是我同时有更多的结果,函数应该为每个mySQL结果运行,而不仅仅是第一个结果

我不知道我是不是需要一辆foreach什么的。我对数组和php循环一无所知

多谢各位

include_once("../dbconnection.php");
date_default_timezone_set('UTC');
$TimeZone ="UTC";
$todaydate = date('Y-m-d') ."\n";
$time_utc=mktime(date('G'),date('i'),date('s'));
$NowisTime=date('G:i:s',$time_utc);
$MembID =(int)$_COOKIE['Loggedin'];
$DB = new DBConfig();
$DB -> config();
$DB -> conn();
$queryMAIN="SELECT * FROM TableTuit WHERE TimeZone ='".$TimeZone."' AND Date ='".$todaydate."' ORDER BY ID ASC";
$result=mysql_query($queryMAIN) or die("Errore select TableT: ".mysql_error());
$tot=mysql_num_rows($result);

while($ris=mysql_fetch_array($result)){
    $text=$ris['Tuitting'];
    $account=$ris['IDAccount'];
    $memberID=$ris['memberID'];
    $type=$ris['Type'];
    $id=$ris['ID'];
    $time=$ris['Time'];

    if($time <= $NowisTime){
    if($type=="F") //if the row type is = F, then do the things below
    {
    $queryF ="SELECT * FROM `TableF` WHERE `memberID`='$MembID' AND `ID`='$account'";
    $result=mysql_query($queryF) or die("Errore select f: ".mysql_error());
    $count = mysql_num_rows($result); 
    if ($count > 0) {
    $row = mysql_fetch_assoc($result);
        DO FUNCTION // Should call the function that requires the above selected values from $queryF. Should Run this function for every mysql result given by $queryMAIN where row "type" is = F
        } 
} 
}

    if($type=="T") //if the row type is = T, then do the things below
    {
    $queryT = $queryF ="SELECT * FROM `TableT` WHERE `memberID`='$MembID' AND `ID`='$account'";
    $result=mysql_query($queryT) or die("Errore select $queryT: ".mysql_error());
    $count = mysql_num_rows($result); 
    if ($count == 0)
    $Isvalid = false;
    else
    {   
    $Isvalid = true;
    $row = mysql_fetch_assoc($result);

    }

    if($Isvalid){

    DO THIS FUNCTION // Should call the function that requires the above selected values from $queryT. Should Run this function for every mysql result given by $queryMAIN where row "type" is = T

    }
    }
}
}//END OF MYSQL WHILE OF $queryMAIN
include_once(../dbconnection.php”);
日期\默认\时区\设置('UTC');
$TimeZone=“UTC”;
$todaydate=日期('Y-m-d')。“\n”;
$time_utc=mktime(日期('G')、日期('i')、日期('s'));
$NowisTime=date('G:i:s',$time\u utc);
$MembID=(int)$_COOKIE['Loggedin'];
$DB=new DBConfig();
$DB->config();
$DB->conn();
$queryMAIN=“从表中选择*,其中时区=”“$TimeZone.”和日期=”“$todaydate.”“按ID ASC排序”;
$result=mysql\u query($queryMAIN)或die(“Errore select table:”.mysql\u error());
$tot=mysql\u num\u行($result);
而($ris=mysql\u fetch\u数组($result)){
$text=$ris['Tuitting'];
$account=$ris['IDAccount'];
$memberID=$ris['memberID'];
$type=$ris['type'];
$id=$ris['id'];
$time=$ris['time'];
如果($time 0){
$row=mysql\u fetch\u assoc($result);
DO FUNCTION//应该调用需要从$queryF中选择上述值的函数。应该为$queryMAIN给出的每个mysql结果运行此函数,其中行“type”为=F
} 
} 
}
if($type==“T”)//如果行类型为=T,则执行以下操作
{
$queryT=$queryF=“从'TableT'中选择*,其中'memberID`='$MembID'和'ID`='$account';
$result=mysql\u query($queryT)或die(“Errore select$queryT:”.mysql\u error());
$count=mysql\u num\u行($result);
如果($count==0)
$Isvalid=false;
其他的
{   
$Isvalid=true;
$row=mysql\u fetch\u assoc($result);
}
如果($Isvalid){
DO THIS FUNCTION//应该调用需要从$queryT中选择上述值的函数。应该为$queryMAIN给出的每个mysql结果运行此函数,其中行“type”为=T
}
}
}
}//$queryMAIN的MYSQL结束

如果要将结果加载到数组中,请尝试在while循环中使用此选项:

while($ris=mysql_fetch_assoc($result)){

如果要将结果加载到数组中,请尝试在while循环中使用此选项:

while($ris=mysql_fetch_assoc($result)){

您正在使用
$result
进行外部查询(
$result=mysql\u Query($queryMAIN);
和while循环内的查询
$result=mysql\u Query($queryF);
-我相信您不想混合使用这些

现在,您处理TableTuit中的第一行,然后用TableF或TableT中的一行覆盖
$result
。在下一个循环中,数组中将找不到以下列(当然,除非它们也在这两个表中):


您正在使用
$result
进行外部查询(
$result=mysql\u Query($queryMAIN);
和while循环内的查询
$result=mysql\u Query($queryF);
-我相信您不想混合使用这些

现在,您处理TableTuit中的第一行,然后用TableF或TableT中的一行覆盖
$result
。在下一个循环中,数组中将找不到以下列(当然,除非它们也在这两个表中):