This is my first question I hope I can make myself understood, what happens is that I'm doing a small script in php and mysql, something similar to plugin polylang for wordpress, so far all right only I need that in the table where I show the records of the published contents show me this way:
- es = Spanish
- en = English
- pt = Portugues
- (+) = has not been created yet.
table view with records already entered, where I want it to look like that.
- id - title - es - en - pt
- 6 - English - + - 6 - +
- 5 - Adeus - 3 - 4 - 5
- 4 - Bye - 3 - 4 - 5
- 3 - Goodbye - 3 - 4 - 5
- 2 - Hello - 1 - 2 - +
- 1 - Hello - 1 - 2 - +
As you can see in the image, I am armed with the table and I have been able to show the ids if they are registered with a check, now I need to show the other buttons, in id = 1 in the "in" column I need to show a button with a pencil icon being its id = 2 and that it takes me to its edition, and in the column of the language "pt" to show the button with the icon + since it is not yet registered that language related to the record 1 and 2, that takes me even empty form to be able to add it, in register 2 the column of the language "is" show me a button with a pencil since that one is already added and above is the father of record 2, hopefully let me understand.
here are my BD tables:
CREATE TABLE 'posts' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'id_categoria' int(11) NOT NULL,
'imagen' varchar(45) DEFAULT NULL,
'estado' int(11) DEFAULT NULL,
'fecha_registro' datetime DEFAULT NULL,
'fecha_edicion' datetime DEFAULT NULL,
'id_usuario' int(11) NOT NULL,
'id_sibling' int(11) DEFAULT NULL,
'post_estado' int(11) DEFAULT NULL,
PRIMARY KEY ('id')
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
CREATE TABLE 'post_langs' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'id_post' int(11) DEFAULT NULL,
'id_lang' int(11) DEFAULT NULL,
'titulo' varchar(255) DEFAULT NULL,
'contenido' text,
'slug' varchar(255) DEFAULT NULL,
PRIMARY KEY ('id')
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
CREATE TABLE 'langs' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'codigo' varchar(2) DEFAULT NULL,
'nombre' varchar(20) DEFAULT NULL,
PRIMARY KEY ('id')
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
and in this way I showed it in the table
<tbody>
{foreach item=datos from=$blog}
<tr>
<td>{$datos.titulo}</td>
<td>{$datos.usuario}</td>
<td>{$datos.nombre}</td>
{foreach item=lang from=$langs}
<td>
{if $datos.id_lang == $lang.id}
<a class="btn btn-info btn-sm" href="blog/editar/{$datos.id}">
<i class="fa fa-check"></i>
</a>
{elseif $datos.id_sibling !== 0 && $lang.id_lang}
<a class="btn btn-secondary btn-sm" href="blog/nuevo">
<i class="fa fa-plus"></i>
</a>
{/if}
</td>
{/foreach}
<td>{date("d/m/Y", strtotime($datos.fecha_registro))}</td>
</tr>
{/foreach}
</tbody>
Thanks for your prompt help