Page 1 of 1

Mixing PHP with HTML Tags

Posted: Fri Jan 30, 2004 11:16 am
by predolim
Hi.

I´m having serious problems with mixing PHP and HTML TAGS.

I´m writing a php/mysql code where mysql db brings all the data to build a dymanic table with mysql data already inserted.

My doubts are:

1) How could use CSS with PHP?


2) Is there any ways to use PHP tags insdie HTML page, inputing PHP tags inside HTML tags as TD TR or even TABLE?

I thank you all in advance for that.

Posted: Fri Jan 30, 2004 11:19 am
by markl999
Example :

Code: Select all

<html>
<head>
<title><?php echo $title ?></title>
<link rel="stylesheet" type="text/css" href="/styles/default.css">
</head>
<body>
<table>
    <tr>
        <td><?php echo $firstName ?></td>
    </tr>
</table>
</body>
</html>

Posted: Fri Jan 30, 2004 11:20 am
by AVATAr
i recomend you to read some basic php tutorial:

http://www.linuxforum.com/phpmanual/introduction.html
http://www.php.net/tut.php

you only have to echo what you want...

Posted: Fri Jan 30, 2004 11:23 am
by predolim
AVATAr wrote:i recomend you to read some basic php tutorial:

http://www.linuxforum.com/phpmanual/introduction.html
http://www.php.net/tut.php

you only have to echo what you want...
I´m trying to do this:

<?php
include "conexao.php";
$sql="select id_not, titulo, texto, link FROM noticias ORDER BY id_not DESC LIMIT 0, 4";
$resultado=mysql_query($sql);
$num_linhas=mysql_num_rows($resultado);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>..:: Terra Networks & Solutions do Brasil ::..</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="tabela.css" rel="stylesheet" type="text/css">
<script src="matrix.js" type="text/javascript" runat="server"></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/detail_2.gif')">
<table width="762" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="1" bgcolor="#000000"rowspan="100"><img src="images/spacer.gif" width="1" height="1"></td>
<td width="760" valign="top"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td height="135" colspan="3" align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shoc ... n=6,0,29,0" width="760" height="135">
<param name="movie" value="top.swf">
<param name="quality" value="high">
<param name="menu" value="false">
<embed src="top.swf" width="760" height="135" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed></object>
</td>
</tr>
<tr>
<td width="171" align="center" valign="top" background="images/esq.gif">
<?php
echo "<table width='168'>";
echo "<tr>";
echo "<td width='168'>";
for ($i=0;$i<$num_linhas;$i++)
{
$dados = mysql_fetch_array($resultado);
echo "<br>";
echo "<font face='Tahoma' size='1' color='#000000' align='justify'>";
echo $dados["titulo"];
echo "<br>";
echo "<img src="images/header.gif" width="171" height="31" border="0">";
echo "<br>";
echo "<a href=".$dados['link']." target='meio'>";
echo $dados["texto"];
echo "</font>";
echo "<br>";
echo "<br>";
}
echo "</td>";
echo "</tr>";
echo "</tr>";
echo "</table>";
?>

</td>
<td width="418" valign="top"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5">&nbsp;</td>
</tr>
<tr>
<td colspan="5"><img src="images/planos_01.jpg" width="209" height="100"><img src="images/planos_02.jpg" width="209" height="100"></td>
</tr>
<tr>
<td rowspan="2"><img src="images/planos.gif" width="184" height="35"></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td background="images/butsplanosbg.gif"><img src="images/abre.gif" width="44" height="24"></td>
<td background="images/butsplanosbg.gif"> <div align="center"><img src="images/butsplanos_01.gif" width="50" height="24"></div></td>
<td background="images/butsplanosbg.gif"> <div align="center"><img src="images/butsplanos_02.gif" width="50" height="24"></div></td>
<td background="images/butsplanosbg.gif"> <div align="center"><img src="images/butsplanos_03.gif" width="50" height="24"></div></td>
</tr>
<tr>
<td width="198"class="feature"><font size="2">ajksvhdajklasdvhla</font></td>
<td class="butdetails" id="CT1_TGLink" onClick="javascript:toggleL('CT1_TGContent','CT1_TGLink')">
<img alt="Veja mais detalhes" src="images/detail.gif" width="44" style="cursor:help;" height="20" border="0"></td>
<td class="details" width="65"> <div align="center">10</div></td>
<td class="details" width="65"> <div align="center">20</div></td>
<td class="canto" width="65"> <div align="center">30</div></td>
</tr>
<tr>
<td colspan="5"> <div id="CT1_TGContent" style="background-color:#FFFFFF" class="TG_hidden">
<div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="description"><span>&ccedil;asdkbnalksdnaklsd<br>
&ccedil;asdkbnalksdnaklsd<br>
&ccedil;asdkbnalksdnaklsd</span></td>
</tr>
</table>

but i´m having problems...

Posted: Fri Jan 30, 2004 11:29 am
by AVATAr
que problemas?

Posted: Fri Jan 30, 2004 11:30 am
by predolim
ótimo, vc fala português..

Na verdade é isso que quero fazer:

Teria como eu usar o CSS dentro do PHP, tipo, nas tabelas criadas dinamicamente, teria como eu usar classes pra manipular o que fosse impresso na tela?

Eu tô tentando fazer isso aqui e não dá certo...

No ínício do código eu faço a conexão com BD
----------------------------------------------------------------
<?php
include "conexao.php";
$sql="select id_not, titulo, texto, link FROM noticias ORDER BY id_not DESC LIMIT 0, 4";
$resultado=mysql_query($sql);
$num_linhas=mysql_num_rows($resultado);
?>

----------------------------------------------------------------

Mais abaixo, junto do HTML eu uso isso aqui
---------------------------------------------------------------
<?php
echo "<table width='168'>";
echo "<tr>";
echo "<td width='168'>";
for ($i=0;$i<$num_linhas;$i++)
{
$dados = mysql_fetch_array($resultado);
echo "<br>";
echo "<font face='Tahoma' size='1' color='#000000' align='justify'>";
echo $dados["titulo"];
echo "<br>";
echo "<img src=\"images/header.gif\" width=\"171\" height=\"31\" border=\"0\">";
echo "<br>";
echo "<a href=".$dados['link']." target='meio'>";
echo $dados["texto"];
echo "</font>";
echo "<br>";
echo "<br>";
}
echo "</td>";
echo "</tr>";
echo "</tr>";
echo "</table>";
?>

Tá certo isso??? É ai no segundo bloco que preciso usar o CSS...qdo forem criadas as tabelas dinâmicas eu preciso inserir o CSS nelas...

Posted: Fri Jan 30, 2004 11:33 am
by Straterra
No hablamos mucho espanol.

Did I say that right? Prolly not!

Posted: Fri Jan 30, 2004 11:35 am
by predolim
Sorry, its portuguese.

I want to do this:

I need to use CSS on PHP dynamic tables

Begining the PHP code
----------------------------------------------------------------
<?php
include "conexao.php";
$sql="select id_not, titulo, texto, link FROM noticias ORDER BY id_not DESC LIMIT 0, 4";
$resultado=mysql_query($sql);
$num_linhas=mysql_num_rows($resultado);
?>

----------------------------------------------------------------

Above, with HTML mixed i have this..
---------------------------------------------------------------
<?php
echo "<table width='168'>";
echo "<tr>";
echo "<td width='168'>";
for ($i=0;$i<$num_linhas;$i++)
{
$dados = mysql_fetch_array($resultado);
echo "<br>";
echo "<font face='Tahoma' size='1' color='#000000' align='justify'>";
echo $dados["titulo"];
echo "<br>";
echo "<img src=\"images/header.gif\" width=\"171\" height=\"31\" border=\"0\">";
echo "<br>";
echo "<a href=".$dados['link']." target='meio'>";
echo $dados["texto"];
echo "</font>";
echo "<br>";
echo "<br>";
}
echo "</td>";
echo "</tr>";
echo "</tr>";
echo "</table>";
?>

Is that right? Could i put CSS on that?

Posted: Fri Jan 30, 2004 11:36 am
by AVATAr
no hablo portugues.. pero somos vecinos (uruguay - español) .. ;)

Solamente tiene que insertar el css.. el css es como html.. simplemente inserta los tags apropiados en los echo.

que queres hacer con css?

---

traduction:

i dont speak portuguese buy we are neightbors (uruguay - spanish)
you only need to insert css tags as html tags. Simply insert the appropiate css tags in the "echos"

what to you want to do with css exactly?

Posted: Fri Jan 30, 2004 1:50 pm
by Unipus
PHP can write any text you want. HTML, CSS, raw data, whatever. So it seems like your real problem is with client-side CSS.