首页 > 解决方案 > 我无法按我的意愿显示程序

问题描述

我不确定如何继续以在我的网站上显示我的 MySQL 的结果。我知道我的程序在本地有效。我只能显示其中一个选择,当我用一个选择打印结果时,我想在两行上显示,但我不能,所以我想提出一些建议。我在其他帖子上没有找到任何明确的答案

use kino;
DROP procedure IF EXISTS `nbrCas`;
DROP procedure IF EXISTS `Ville`;
DROP procedure IF EXISTS `Police`;
delimiter $$

create  procedure nbrCas()
begin
    DECLARE cnt INT DEFAULT 0 ;
    DECLARE max INT DEFAULT 0 ;
    DECLARE year int DEFAULT 0 ;
    DECLARE minYear int DEFAULT 50 ;
    DECLARE maxYear int DEFAULT 0 ;
    DECLARE counterYear int DEFAULT 0;
    DECLARE big int default 0 ;
    DECLARE min int default 50 ;
    create temporary table year select DISTINCT YEAR(Ertaussstrahlung) from folge ;
    
    select count(*) into max from year;
    WHILE cnt < max
    DO
        set year=(select * from year limit 1 offset cnt);
        set counterYear = (select count(*) from folge where Ertaussstrahlung >=CONCAT(year,'-','01','-','01') and Ertaussstrahlung < CONCAT((year + 1),'-','01','-','01')) ;
        IF counterYear > big
        THEN
            set big = counterYear;
            set maxYear = year;
        END IF;
        IF counterYear < min
        then
            set min = counterYear;
            set minYear = year;
        END IF;
    
        SET cnt=cnt+1;
    END WHILE;
    select "L'année ayant eu le plus de cas:", maxYear,"\n";
    select "L'annee ayant eu le plus de cas:",minYear;
    
    drop table year;
END;
create procedure Ville()
begin
    DECLARE max int DEFAULT 0 ;
    DECLARE cnt int DEFAULT 0 ;
    DECLARE ville varchar(100);
    DECLARE counterVille int DEFAULT 0 ;
    DECLARE biggest int DEFAULT 0 ;
    DECLARE smallest int DEFAULT 1000 ;
    DECLARE villeWin varchar(100);
    DECLARE villeMin varchar(100);
    create temporary table ville select DISTINCT(stadt) from folge ;
    select count(*) into max from ville;
    WHILE cnt < max
    DO
        set ville = (select * from ville limit 1 offset cnt);
        
        SET counterVille = (select count(*) from folge where stadt=ville);
        IF counterVille > biggest
        then
            set biggest = counterVille;
            set villeWin = ville;
        END IF;
        IF counterVille < smallest
        then
            set smallest = counterVille;
            set villeMin = ville;
        END IF;
        set cnt = cnt +1;
    END WHILE;
    select biggest;
    select villeWin;
    select smallest;
    select villeMin;
    drop table ville;
END;

create procedure Police()
begin
    DECLARE max int DEFAULT 0 ;
    DECLARE cnt int DEFAULT 0 ;
    DECLARE Policier varchar(100);
    DECLARE counterPolicier int DEFAULT 0 ;
    DECLARE biggest int DEFAULT 0 ;
    DECLARE smallest int DEFAULT 1000 ;
    DECLARE PolicierMin varchar(100) ;
    DECLARE PolicierMax varchar(100) ;


    create temporary table police select DISTINCT(Ermittler) from folge ;
    select count(*) into max from police;

    WHILE cnt < max
    DO
        set Policier = (select * from police limit 1 offset cnt);
        set counterPolicier = (select count(*) from folge where Ermittler = Policier);
        IF counterPolicier > biggest
        then
            set biggest = counterPolicier;
            set PolicierMax = Policier;
        END IF;
        IF counterPolicier < smallest
        then
            set smallest = counterPolicier;
            set PolicierMin = Policier;
        END IF;
        set cnt = cnt + 1;
    END WHILE;
    select biggest;
    select PolicierMax;
    select smallest;
    select PolicierMin;
    drop table police;
END;
$$

<?php
    $gateway = new EpisodeGateway();    
   $db = $gateway->acces_db();
   $result = array();
   $result = mysqli_query($db,'call nbrCas');
   $result = mysqli_fetch_all($result);
   foreach($result as $val)
   {
    foreach($val as $value)
    {
        echo $value;
    }
   }
?>

标签: phpmysql

解决方案


推荐阅读