Jump to content

Search the Community

Showing results for tags 'status'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. Code what i made so far. Your comments at what should i do differently. My configs.php <?php $userQuery = 'SELECT * FROM users WHERE id = :id'; $user = $db->prepare($userQuery); $user->bindParam(':id', $_SESSION['userId'], PDO::PARAM_INT); $user->execute(); $userInfo = $user->fetch(PDO::FETCH_ASSOC); ?> functions.php <?php function loginCheck(){ global $db; if(isset($_SESSION['userId'], $_SESSION['loginString'])){ $query = 'SELECT username FROM users WHERE id = :id'; $user = $db->prepare($query); $user->bindParam(':id', $_SESSION['userId'], PDO::PARAM_INT); $user->execute(); $row = $user->fetch(PDO::FETCH_ASSOC); if($user->rowCount() == 1){ if(hash('sha512', $row['username'].$_SERVER['HTTP_USER_AGENT']) == $_SESSION['loginString']){ return true; }else{ return false; } }else{ return false; } }else{ return false; } } function checkUserRole(){//can be user, admin and moderator global $userInfo; if($userInfo['userRole'] == 'admin' or $userInfo['userRole'] == 'moderator'){ return true; }else{ return false; } } ?> shoutbox.php Can this be done with one query? global $db, $userInfo; $sbQuery = 'SELECT * FROM shoutbox ORDER BY dateCreated DESC LIMIT 30'; $sb = $db->query($sbQuery); $usersQuery = 'SELECT * FROM users WHERE shoutBoxBan = "yes"'; $users= $db->query($usersQuery); $usersRow = $users->fetch(PDO::FETCH_ASSOC); $hiddenAction = ''; while($sbRow = $sb->fetch(PDO::FETCH_ASSOC)){ if(loginCheck() and checkUserRole()){ $hiddenAction = " <a href=\"javascript:;\" onClick=\"deleteMessage('".$sbRow['id']."')\" class=\"shoutBoxDelete\" title=\"Delete\">x</a>"; if($usersRow['username'] == $sbRow['username']){ $hiddenAction .= " <a href=\"javascript:;\" onClick=\"unBan('".$sbRow['username']."')\" class=\"shoutBoxBan\" title=\"Unban\">u</a>"; }else{ if($userInfo['username'] != $sbRow['username']){//admin and moderator cant ban themselves. $hiddenAction .= " <a href=\"javascript:;\" onClick=\"banUser('".$sbRow['username']."')\" class=\"shoutBoxBan\" title=\"Ban\">o</a>"; $hiddenAction .= " <a href=\"javascript:;\" onClick=\"tempBanUser('".$sbRow['username']."')\" class=\"shoutBoxBan\" title=\"Temp Ban\">ΓΈ</a>"; } } } ....................................
  2. Doesn't change status to expired. <?php $bannersQuery = 'SELECT * FROM banners WHERE expire > NOW() AND status = "active" ORDER BY RAND() LIMIT 10'; $banners = $db->query($bannersQuery); while($row = $banners->fetch(PDO::FETCH_ASSOC)){ if($row['expire'] <= time()){ $status = 'expired'; }else{ $status = 'active'; } $updateQuery = 'UPDATE banners SET exposures = exposures + 1, status = :status WHERE id = :id'; $update = $db->prepare($updateQuery); $update->bindParam(':status', $status, PDO::PARAM_STR); $update->bindParam(':id', $row['id'], PDO::PARAM_INT); $update->execute(); echo ' <a href="index.php?do=bannerClick&id='.$row['id'].'" target="_BLANK"><img src="'.$row['url'].'" width="'.$row['width'].'" height="'.$row['height'].'" alt="'.$row['title'].'"></a><br>'; } echo ' <a href="index.php?do=buyBanner">Want to advertise your banner? Click here.</a>'; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.