Jump to content
Fórum Script Brasil
  • 0

gerador de tabelas html com php


Question

o objetivo dessa tabela é simples, quando coloco as informações na textarea a mesma deve aparecer e quando não preencho as celulas dessa tabela tambem não devem aparecer, bom até ai esta tudo ocorrendo certo, porém essa tabela tem q ser zebrada e quando eu deixo de colocar uma das informações as cores se repetem e não ficam zebradas (isso ocorre porque nem sempre vou colocar todas as informações da text area).

<?php

if(isset($_POST)){
	$t1a = $_POST['txt1a'];
	$t1b = str_replace("\r\n",'<br />',$_POST['txt1b']);
	$t2a = $_POST['txt2a'];
	$t2b = str_replace("\r\n",'<br />',$_POST['txt2b']);
	$t3a = $_POST['txt3a'];
	$t3b = str_replace("\r\n",'<br />',$_POST['txt3b']);
	$t4a = $_POST['txt4a'];
	$t4b = str_replace("\r\n",'<br />',$_POST['txt4b']);
	$t5a = $_POST['txt5a'];
	$t5b = str_replace("\r\n",'<br />',$_POST['txt5b']);
	$t6a = $_POST['txt6a'];
	$t6b = str_replace("\r\n",'<br />',$_POST['txt6b']);
	$t7a = $_POST['txt7a'];
	$t7b = str_replace("\r\n",'<br />',$_POST['txt7b']);
	$t8a = $_POST['txt8a'];
	$t8b = str_replace("\r\n",'<br />',$_POST['txt8b']);
	$t9a = $_POST['txt9a'];
	$t9b = str_replace("\r\n",'<br />',$_POST['txt9b']);
	$t10a = $_POST['txt10a'];
	$t10b = str_replace("\r\n",'<br />',$_POST['txt10b']);
	$t11a = $_POST['txt11a'];
	$t11b = str_replace("\r\n",'<br />',$_POST['txt11b']);
	$t12a = $_POST['txt12a'];
	$t12b = str_replace("\r\n",'<br />',$_POST['txt12b']);
	$t13a = $_POST['txt13a'];
	$t13b = str_replace("\r\n",'<br />',$_POST['txt13b']);
	$t14a = $_POST['txt14a'];
	$t14b = str_replace("\r\n",'<br />',$_POST['txt14b']);
	$t15a = $_POST['txt15a'];
	$t15b = str_replace("\r\n",'<br />',$_POST['txt15b']);
	
	if(empty($t1a)){
		echo '<script>alert(" \n\Oops,\nO título do artigo é essencial!\n\nPreencha-o e tente novamente. ");</script>';
		exit;
	}
	
	$tab = '<!-- Título -->\n';	
	$tab .= '<div style=\"font-size:16pt; font-weight:bold; padding:10px; font-family: Roboto;\">'.$t1a.'</div>\n';
	
	if(!empty($t1a) && !empty($t1b)){ 
		$tab .= '<!-- Descrição -->\n';
		$tab .= '<div style=\"font-size:12pt; padding:10px; font-family: Roboto;\">'.$t1b.'</div>\n\n';
	}
	$tab .= '<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-family:Roboto, sans-serif;\">\n';
	$tab .= '<tbody>\n\n';					
	
	if(!empty($t2a) && !empty($t2b)) {
		$tab .= '<!-- Linha 1 -->\n';
		$tab .= '<tr style=\"background-color:#D9E2F3;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; padding:5px; font-size:10pt; font-weight:800;\">'.$t2a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; padding:5px; font-size:10pt;\">'.$t2b.'</td>\n';
		$tab .= '</tr>\n\n';
	}

	if(!empty($t3a) && !empty($t3b)){
		$tab .= '<!-- Linha 2 -->\n';
		$tab .= '<tr style=\"background-color:#EEEEEE;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t3a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t3b.'</td>\n';
		$tab .= '</tr>\n\n';
	}

    if(!empty($t4a) && !empty($t4b)){
		$tab .= '<!-- Linha 3 -->\n';
		$tab .= '<tr style=\"background-color:#D9E2F3;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t4a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t4b.'</td>\n';
		$tab .= '</tr>\n\n';
	}

	if(!empty($t5a) && !empty($t5b)){ 
		$tab .= '<!-- Linha 4 -->\n';
		$tab .= '<tr style=\"background-color:#EEEEEE;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t5a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t5b.'</td>\n';
		$tab .= '</tr>\n\n';
	}
	
	if(!empty($t6a) && !empty($t6b)){ 
		$tab .= '<!-- Linha 5 -->\n';
		$tab .= '<tr style=\"background-color:#D9E2F3;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t6a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t6b.'</td>\n';
		$tab .= '</tr>\n\n';
	}
	
	if(!empty($t7a) && !empty($t7b)){ 
		$tab .= '<!-- Linha 6 -->\n';
		$tab .= '<tr style=\"background-color:#EEEEEE;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t7a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t7b.'</td>\n';
		$tab .= '</tr>\n\n';
	}
	
	if(!empty($t8a) && !empty($t8b)){ 
		$tab .= '<!-- Linha 7 -->\n';
		$tab .= '<tr style=\"background-color:#D9E2F3;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t8a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t8b.'</td>\n';
		$tab .= '</tr>\n\n';
	}
	
	if(!empty($t9a) && !empty($t9b)){ 
		$tab .= '<!-- Linha 8 -->\n';
		$tab .= '<tr style=\"background-color:#EEEEEE;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t9a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t9b.'</td>\n';
		$tab .= '</tr>\n\n';
	}
	
	if(!empty($t10a) && !empty($t10b)){ 
		$tab .= '<!-- Linha 9 -->\n';
		$tab .= '<tr style=\"background-color:#D9E2F3;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t10a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t10b.'</td>\n';
		$tab .= '</tr>\n\n';
	}
	
	if(!empty($t11a) && !empty($t11b)){ 
		$tab .= '<!-- Linha 10 -->\n';
		$tab .= '<tr style=\"background-color:#EEEEEE;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t11a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t11b.'</td>\n';
		$tab .= '</tr>\n\n';
	}
	
	if(!empty($t12a) && !empty($t12b)){ 
		$tab .= '<!-- Linha 11 -->\n';
		$tab .= '<tr style=\"background-color:#D9E2F3;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t12a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t12b.'</td>\n';
		$tab .= '</tr>\n\n';
	}
	
	if(!empty($t13a) && !empty($t13b)){ 
		$tab .= '<!-- Linha 12 -->\n';
		$tab .= '<tr style=\"background-color:#EEEEEE;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t13a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t13b.'</td>\n';
		$tab .= '</tr>\n\n';
	}
	
	if(!empty($t14a) && !empty($t14b)){ 
		$tab .= '<!-- Linha 13 -->\n';
		$tab .= '<tr style=\"background-color:#D9E2F3;\">\n';
		$tab .= '<td width=\"20%\" style=\"border:1px solid #AAAAAA; border-top:none; padding:5px; padding-top:5px; font-size:10pt; font-weight:800;\">'.$t14a.'</td>\n';
		$tab .= '<td width=\"80%\" style=\"border:1px solid #AAAAAA; border-left:none; border-top:none; padding:5px; padding-top:5px; font-size:10pt;\">'.$t14b.'</td>\n';
		$tab .= '</tr>\n\n';
	}		
	
	$tab .= '</tbody>\n';
	$tab .= '</table>\n';
	
	if(!empty($t15a)){ 
		$tab .= '<!-- descrição extra do artigo -->\n';
		$tab .= '<div style=\"font-size:14pt; font-family: Roboto; padding:5px; padding-top:10px; font-weight:900;\">'.$t15a.'</div>\n';
		$tab .= '<div style=\"font-size:12pt; font-family: Roboto; padding:5px; padding-top:10px; font-weight:900;\">'.$t15b.'</div>\n';	
	}
  echo '<script>
		  $(function(){
			  $("#preto").show();
			  $("#modalHtml").modal("show");
			  $("#gerado").val("'.$tab.'");
		  });
		  </script>';
}
  
  

 

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      149178
    • Total Posts
      645430
×
×
  • Create New...