php - Show record from db only one time to user -
i want show new record user 1 time. know can achieved using cookies, how use in situation? have record in $row .
$con = mysqli_connect("localhost", "root", "", "dentistf_new_df"); if(mysqli_connect_errno()) { echo "failed connect mysql: ".mysqli_connect_error(); } $query = mysqli_query($con, "select * wp_blog_posts order id desc "); while($row = $query->fetch_assoc()) { if(in_array($row['id'], $_cookie['blog_id _status'])) { nothing... } else { echo $row['id']; setcookie('blog_id _status', $row['id']); } }
when set data cookie setcookie() on 1 page, can 1 second page:
if(isset($_cookie['mydata'])) { echo $_cookie['mydata']; setcookie("mydata", "", time()-(60*60*24), "/"); // unsets cookie }
dont use $_cookie['blog_id _status'] = '';
set value cookies.
Comments
Post a Comment