Neden sorgu İlk satırı dışında eksik?

0 Cevap php

Ben belirli bir gece katılıyor tüm kullanıcıları silmek için izin veren bir komut dosyası oluşturduk. Hepsini silmek için seçmeden önce komut bir tablo bu kullanıcıların tüm gösterecektir. Nedense bu olsa ilk plağı dışarı özlüyor ...

<?php # delete_guest.php

// this page is for deleting a guest

// this page is accessed through view_users.php

$page_title = 'Delete all Guests';

include ('includes/header.html');

echo '<h1>Delete all Guests for a night</h1>';

if ( (isset($_GET['id']))) //From view_user.php

{   
$id = $_GET['id'];
}

elseif ( (isset($_POST['id']))) //Form Submission

{
$id = $_POST['id'];
}

else { //No valid ID, Kill the script
    echo '<p class="error">This page has been accessed in error.</p>';
    include ('includes/footer.html');
    exit();
}

require_once ('../mysqli_connect.php');

// check if the form is submitted
if (isset($_POST['submitted'])) {

    if ($_POST['sure'] == 'Yes') { //delete the records

        $q = "DELETE FROM guests WHERE night_attending=$id";
        $r = @mysqli_query ($dbc, $q);

        if (mysqli_affected_rows($dbc) >0){ //if it ran ok

            echo '<p>The guest has been deleted.</p';
        }
        else { // if it didn't run ok

            echo '<p class="error">The guest could not be deleted due to a system error</p>';
            echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; // debugging message
        }
    }
    else{ // no comfirmation of deletion

        echo '<p>The guest has NOT been deleted.</p>';
    }
}
else{  // show the form

    $q = "SELECT last_name, first_name, user_id, email, DATE_FORMAT(night_attending, '%d/%m/%Y') AS na FROM guests  WHERE night_attending='$id'"; // select the data
    $r = @mysqli_query ($dbc, $q); // Run the query.

    if (mysqli_num_rows($r) >0) { // valid id, show the form

        // get the user's information
        $row = mysqli_fetch_array ($r, MYSQLI_NUM);

        echo //create the form
        '<form action="delete_allguests.php" method="post"> 

            <p>
                Are you sure you want to delete all the guests from this night?<br />

                <input type="radio" name="sure" value="Yes" /> Yes
                <input type="radio" name="sure" value="No" checked="checked"/> No       
            </p>

            <p><input type="submit" name="submit" value="Submit" /></p>

            <input type="hidden" name="submitted" value="TRUE" />
            <input type="hidden" name="id" value="' . $id . '" />
            <hr />          
        </form>';


        // Table header
        echo '<br />
            <table align="center" cellscpacing="3" cellpadding="3" width="75%">
            <tr>
                <td align="left"><b>First Name</b></td>
                <td align="left"><b>Last Name</b></td>
                <td align="left"><b>Email</b></td></td>
                <td align="left"><b>Date Attending</b></td>
            </tr>';

    // Fetch and print all the records:
    while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
        echo '
        <tr>
            <td align="left">' . $row['last_name'] . '</td>
            <td align="left">' . $row['first_name'] . '</td>
            <td align="left">' . $row['email'] .'</td>
            <td align="left">' . $row['na'] . '</td></tr>           
        ';
    }

    echo '</table>'; // Close the table.


        mysqli_free_result ($r); // Free up the resources.  

    } else { // If no records were returned.

        echo '<p class="error">There are currently no guests on the list for this night.</p>';

    }
}   

mysqli_close($dbc);

include ('includes/footer.html');


?>

böylece sayfadaki tüm kodu dahil, üzgünüm ettik hata yalan nerede emin değil im.

herhangi bir fikir?

teşekkürler

alsweet

0 Cevap