0

週末を楽しみにしていてください。:)

いくつかの php/mysql で、組織の再配置にわずかな問題があります。私は完全にうまく機能する次のコードを持っています:

// Get the regions our user is assigned to look after
$result1 = mysqli_query($con,"SELECT * FROM regions WHERE staff_100_id='$id'");
while ($row1 = mysqli_fetch_assoc($result1)) {

    // Now get the claims that have come in for the above regions.
    $result2 = mysqli_query($con,"SELECT * FROM registrar_claims WHERE reg_region='$row1[region]' && ready_to_process='yes' ORDER BY claim_id ASC");
    while ($row2 = mysqli_fetch_assoc($result2)) {

        echo $row2[claim_id] ." ";
        echo $row2[reg_1st_name] ." ";
        echo $row2[reg_2nd_name] ."<br>";

        }
    }
}

これの出力は次のようになります。

2 Roger Ramjet
7 Snobby Bobgrass
5 Num Nut
6 Phil Pott

db 呼び出し内のサイクルごとだけでなく、全体的に claim_id によって配置されるように、出力を出してもらいたいと思います。だから私は出力を次のようにしたい:

2 Roger Ramjet
5 Num Nut
6 Phil Pott
7 Snobby Bobgrass

これを達成するために物事を再配置する方法を誰かが教えてくれませんか?

ありがとうございます!:)

キャス

4

3 に答える 3

0

お役に立てれば:

<?
// Get the regions our user is assigned to look after and all the claims that have come in 
//for the above regions.

$query = 
    "SELECT 
        regions.*,
        registrar_claims.*
    FROM 
        regions inner join registrar_claims on registrar_claims.reg_region = regions.region
    WHERE 
        regions.staff_100_id='$id' and
        registrar_claims.ready_to_process = 'yes'
    ORDER BY
        registrar_claims.claim_id";

while ($row = mysqli_fetch_assoc(mysqli_query($con, $query))) {
        echo $row[claim_id] ." ";
        echo $row[reg_1st_name] ." ";
        echo $row[reg_2nd_name] ."<br>";
}
?>

さらに、コードのセキュリティと明確さのために、準備されたステートメントを確認することをお勧めします。

于 2013-11-08T01:35:55.470 に答える