SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    28
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    how can I delete a row I want to display? I want 2 display the row and then delete it

    any idea is welcome...the things is that I have a number store in the database and I get it display on the page like this 008******************, so when the user click a button like buy the page will load and display the number in full 0088643435355, so now I dont want another user to see the same number cause one user already pay for it and it should be remove from the database...the number as to be display in full for the user who buy it so that they can make use of it, so another user dont have to buy same number..

    I have try it but am getting error message that say.....

    SQLSTATE[42S02]: Base table or view not found: 1109 Unknown table 'id' in MULTI DELETE

    help me find out what am doing wrong....

    PHP Code:
    foreach ($buyMtn100s as $buyMtn100)
    $buyMtnuserId $buyMtn100['id'];
    $mtn100 100;

    if(
    $accountBal == $mtn100 or $accountBal $mtn100) { 
    $buyMtnPinNumber $buyMtn100['pinNumber'];
    $buyMtnPinSerialNumber $buyMtn100['serialNumber'];

    require 
    $_SERVER['DOCUMENT_ROOT'] . '/includes/updateMTN.inc.php';
    $currentBal $accountBal $mtn100;
    $sql 'UPDATE members SET accountBal = :accountBal WHERE id =:id';
    $s $pdo->prepare($sql);
    $s->bindValue(':id'$_SESSION['userId'], PDO::PARAM_STR);
    $s->bindValue(':accountBal'$currentBalPDO::PARAM_STR);
    $s->execute(); // Execute the prepared query.


    include $_SERVER['DOCUMENT_ROOT'] . '/includes/insertUserDB.inc.php';

    $sql ' INSERT INTO history SET
    buyerId =:buyerId,
    buyerPhoneNumber =:buyerPhoneNumber,
    pinId =:pinId,
    pinNumber =:pinNumber,
    pinSerialNumber =:pinSerialNumber,
    buyDateTime = NOW() '
    ;
    $historyStmt $pdo->prepare($sql);
    $historyStmt->bindValue(':buyerId'$_SESSION['userId'], PDO::PARAM_STR);
    $historyStmt->bindValue(':buyerPhoneNumber'$_SESSION['phoneNumber'], PDO::PARAM_STR);
    $historyStmt->bindValue(':pinId'$buyMtnuserIdPDO::PARAM_STR);
    $historyStmt->bindValue(':pinNumber'$buyMtnPinNumberPDO::PARAM_STR);
    $historyStmt->bindValue(':pinSerialNumber'$buyMtnPinSerialNumberPDO::PARAM_STR);
    $historyStmt->execute(); // Execute the prepared query.

    require $_SERVER['DOCUMENT_ROOT'] . '/includes/deleteMTN.inc.php';
    $sql"DELETE id FROM mtn_n100 WHERE id = :id";
    $s $pdo->prepare($sql);
    $s->bindValue(':id'$buyMtnIdPDO::PARAM_STR);
    $s->execute(); // Execute the prepared query.
    ==============================
    echo 
    $buyMtnPinNumber;
    echo 
    $buyMtnPinSerialNumber
    error message
    SQLSTATE[42S02]: Base table or view not found: 1109 Unknown table 'id' in MULTI DELETE

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    DELETE FROM mtn_n100 WHERE id = :id"

    Don't specify the column names after DELETE. You don't delete certain columns, you delete entire rows.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    28
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks @guido2004....everything works fine now...there is one thing I will like to do, when I click the buy button the page will load and display the number in full and also delete it from the database but is still appear on the page when the page return with the full number. until I refresh the page before it get disappear, I hope to delete it while the page reload without needing to refresh cause I think some user might click the buy for the same number again but get error which I try myself..

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by aosworks View Post
    thanks @guido2004....everything works fine now...there is one thing I will like to do, when I click the buy button the page will load and display the number in full and also delete it from the database but is still appear on the page when the page return with the full number. until I refresh the page before it get disappear, I hope to delete it while the page reload without needing to refresh cause I think some user might click the buy for the same number again but get error which I try myself..
    Sorry, you've lost me here. I don't understand what you're trying to say or do.

  5. #5
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,098
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    To make the database update, you will probably need AJAX.
    Then a hide div (javaScript) to hide the div the number is in.
    What I lack in acuracy I make up for in misteaks

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    28
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks @guido...I have try to fix it and everything is working fine now....

    another things am trying to do now it that I want to include html tags when I want to output but I have my value in htmlspecialchars($value) ;

    what I try is htmlspecialchars('<div class="pinProcess">' . $value . "</div>"); }?>

    and I get this output...
    <div class="pinProcess">value</div> display on the screen...

    help me out on how I can do it better....I want to safely output the $value and I want it inside <div class="pinProcess"> value </div>

  7. #7
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,036
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by aosworks View Post
    I want to safely output the $value inside div element and I want the browser to understand it...
    That pretty much dictates how the code should look, doesn't it?

    PHP Code:
    echo '<div class="pinProcess">'htmlspecialchars($value), "</div>"
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  8. #8
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    28
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    [QUOTE

    PHP Code:
    echo '<div class="pinProcess">'htmlspecialchars($value), "</div>"
    [/QUOTE]

    thanks @ScallioXTX...it work fine.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •