The detail of the content or product where I show all the information from my tablecontenido
id_contenido contenido title image author detail url show_temary active
and from it I can directly hide the chapters this would be as private content and, I control it from this point show_temary
where if it has the value of yes
the chapters are shown.
if($show_temary ==="yes") {
//Muestro los capítulos para usuarios registrados o otra cosa para usuarios no registrados
}
Now for users registered as a demo account, a new column called show_chapters
the table was created chapters
where if the value is yes
, that chapter is enabled. Well here I can solve it using the same content or product detail control.
id_chapters chapters id_contenido show_chapters
But my biggest problem is that he wanted to show the chapters and also the content that they cover within the chapters as the days or weeks go by in that way that the chapters and content are enabled, but according to the type of account.
And, my users table is made up as follows.
id_user first_name last_name referred account_type premium_user username email password profile logindatetime log_in email_code expiry_code active
And, my code is
function PlayerList(){
global $id_contenido;
global $conexion;
$active = 1;
$show_chapters = "yes";
$stmt = $conexion->prepare("SELECT id_chapters,chapters FROM chapters WHERE id_contenido=? AND show_chapters=?");
$stmt->bind_param("is",$id_contenido,$show_chapters);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows>0) {
$stmt->bind_result($id_chapters, $chapters);
while ($stmt->fetch()) {
echo '<h1 class="chapters-player">'.$chapters.'</h1>';
$stmtA = $conexion->prepare("SELECT title_video,file_type_format,multimedia,detail_format_text,url_website FROM videos WHERE id_contenido=? AND id_chapters=? AND active=?");
$stmtA->bind_param("iii",$id_contenido,$id_chapters,$active);
$stmtA->execute();
$stmtA->store_result();
if ($stmtA->num_rows>0) {
$stmtA->bind_result($title_video, $file_type_format,$multimedia,$detail_format_text,$url_website);
while ($stmtA->fetch()) {
}
} else {
echo 'Estamos trabajando para el próximo cápitulo';
}
}
} else {
echo 'En estos momentos estamos actualizando el contenido más reciente de este cápitulo.';
}
}
I have managed to advance in certain things mentioned, but I would like to be able to enable the chapters and contents according to the date, controlling said action according to the type of account, can you explain to me how to do it.
it's a bit difficult to understand your explanation, but, if I'm not mistaken, you want the chapters to be displayed according to a specific day and if the user is registered or not. This is an idea that you could apply: the first thing you should do is take the value of
logindatetime
in the users table as a global variable or enclose it in a$_SESSION['fecha_login_usuario']
, this (I imagine) gives you a specific date and time that is updated every time the user log in. Then, you must create a columndate
in the table bychapters
adding a manual date with the same format as the columnlogindatetime
, this date is programmed by you when creating the chapters.Now, first of all, add the global variable with the value of the
logindatetime
brought from the users table.When you do the
SELECT
from the tablechapters
you must add the new columndate
At this point you can place a
if
to validate the date and check that the chapter can be enabled:With this line of code:
$show_chapters = "yes";
you are already validating that they are registered users with a demo account, if I'm not mistaken.I hope I can help you. If you have any problem leave a comment or be more explicit in your explanation.