#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    17
    Rep Power
    0
    Ok. I need to use php to access a cell in a table for the user and check to see if the value is "Yes" or "No".

    If the value is "Yes", then I need php to display "New News", if the value is "No" I need php to display "No New News."

    I'm a newbie at coding (I'm not exaggerating. ), and I think I probably am trying to do it totally wrong! Please help me.

    (btw- I used include to include this file in another page if that makes any difference oh and 'theuser' is a cookie. It works. )

    <HTML>
    <BODY>
    <?php
    $con=mysql_connect('hostname', 'username', 'password');

    mysql_select_db('username',$con);

    $Yes=='Yes'
    $NewNews = mysql_query ("SELECT News FROM Users WHERE Username = '$theuser'",$con);

    if ($NewNews==$Yes){
    echo ("New News!");

    $UpdateIt = mysql_query ("UPDATE Users set News = 'No' WHERE Username = '$theuser'",$con);
    }else{
    print ("No New News");
    exit;}

    ?>
    </BODY>
    </HTML>
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    Ok. I need to use php to access a cell in a table for the user and check to see if the value is "Yes" or "No".
    >>


    Cinela,

    here is the solution for your problem..

    <HTML>
    <BODY>
    <?php
    $con=mysql_connect('hostname', 'username', 'password');
    //connection string

    mysql_select_db('databasename',$con);
    //select the database

    $result = mysql_query ("SELECT News FROM Users WHERE Username = '$theuser'",$con);
    //issue sql statement


    $row=mysql_fetch_array($result);
    //get the row result values from above sql command.

    if ($row["News"]=="Yes"){
    //New News..

    echo "New News!n";

    $UpdateIt = mysql_query ("UPDATE Users set News = 'No' WHERE Username = '$theuser'",$con);
    }else{
    print ("No New News");
    exit;
    }

    ?>
    </BODY>
    </HTML>

    That is it!!!

    Good Luck!!!


    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    17
    Rep Power
    0
    Thank you.

Similar Threads

  1. Help with CREATE TEMPORARY TABLE
    By C3P0 in forum MySQL Help
    Replies: 0
    Last Post: February 16th, 2004, 02:50 PM
  2. League table problem
    By silverduck in forum MySQL Help
    Replies: 8
    Last Post: February 10th, 2004, 12:38 PM
  3. check a value of a select not working
    By horstuff in forum HTML Programming
    Replies: 2
    Last Post: February 3rd, 2004, 12:01 AM
  4. Replies: 0
    Last Post: January 30th, 2004, 02:18 PM
  5. how to keep table on top, not centered??
    By vinyl in forum HTML Programming
    Replies: 2
    Last Post: January 20th, 2004, 06:19 PM

IMN logo majestic logo threadwatch logo seochat tools logo