Question:
The detail of the content or product where I show all the information from my contenido
table
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
was created in the chapters
table 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 how to do it.
Answer:
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 wrap it in a $_SESSION['fecha_login_usuario']
, this (I imagine) gives you a specific date and time which is updated each time the user logs in. Then, you must create a date
column in the chapters
table by adding a manual date with the same format as the logindatetime
column, 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.
function PlayerList(){
global $id_contenido;
global $conexion;
global $login_date;
$active = 1;
$show_chapters = "yes";
When you do the SELECT
from the chapters
table you must add the new date
column
$stmt = $conexion->prepare("SELECT id_chapters,chapters,date FROM chapters WHERE id_contenido=? AND show_chapters=?");
$stmt->bind_param("is",$id_contenido,$show_chapters);
$stmt->execute();
$stmt->store_result();
//obtienes los resultados con el date
if ($stmt->num_rows>0) {
$stmt->bind_result($id_chapters, $chapters, $date);
At this point you can place an if
to validate the date and check that the chapter can be enabled:
while ($stmt->fetch()) {
//Si la fecha de login es mayor o igual a la fecha de programación del capítulo
if ($login_date => $date) {
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 capítulo';
}
} else { //Si la fecha de login es menor a la fecha de programación del capítulo
echo 'Este contenido no está disponible en este momento';
}
}
} else {
echo 'En estos momentos estamos actualizando el contenido más reciente de este capitulo.';
}
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.