Hi,
I'm doing a table that list courses that are in BD, but i'm having some problem, can someone help me?

<?PHP

include 'topo.php';

include 'db_connect.php';

$sql = "SELECT * FROM cursos";
$query = mysql_query($sql,$connect);
?>

<table>

<?PHP
while ($row = mysql_fetch_array($query))
{ 
?>
	<tr>
		<td>
			<div id="navigation-block">  
				<ul id="sliding-navigation">  
					<li class="sliding-element"><a href="prog_curso.php?cod= <?PHP echo $row['cod_curso']; ?> "> <?PHP echo $row['nome_curso']; ?> </a></li>
				</ul>			
			</div>
		</td>
		
		
		<td>
		PROGRAMAÇÃO:
		<?PHP echo $row['prog_curso']; ?>
		</td>
	</tr>
	
	<?PHP
	;}
	?>
</table>

<?PHP

include 'rodape.php';

?>

The error is

Parse error: syntax error, unexpected ';' in C:\wamp\www\site\tabela_cursos.php on line 18

echo ?> <a href="prog_curso.php?cod= <?PHP echo $row['cod_curso']; ?>"> <?PHP echo $row['prog_curso']; ?> </a>

Recommended Answers

All 8 Replies

Member Avatar for Zagga

Hi PF2G,

Try removing the semicolon on line 34.

(The error message shows line 18 because the error is 'near' the 18th line of PHP code, the HTML isn't counted)

Hi PF2G,

Try removing the semicolon on line 34.

(The error message shows line 18 because the error is 'near' the 18th line of PHP code, the HTML isn't counted)

I wasn't close the for operator, but it keeps giving me error in the same line:

<?php

include "db_connect.php";

$sql_imagem = "SELECT cod_curso, prog_curso, imagem_curso, nome_curso FROM cursos ORDER BY nome_curso ASC";
$executa=mysql_query($sql_imagem,$connect);

$dados = array();
while ($linha = mysql_fetch_array($executa)) $dados[] = $linha;
mysql_free_result($executa);


function add_imglink($linha) 
{
    echo '<td align="center">';
		while ($row = mysql_fetch_array($executa))
		{ 
          echo ?> <a href="prog_curso.php?cod= <?PHP $row['cod_curso']; ?>"> <?PHP echo $row['nome_curso']; ?> </a>
		<?PHP}
			  echo '<img src="', $linha['imagem_curso'], '"><br />';
              echo $linha['nome_curso'];
          echo '</a>';
    echo '</td>';
}


define('NUMERO_COLUNAS', 4);
echo '<table width = 90%  height = 45% align = center>';
for ($i = 0; $i < count($dados); $i += NUMERO_COLUNAS) 
{
    echo '<tr>';

    for ($col = 0; $col < NUMERO_COLUNAS; $col++) 
	{
        if ($i + $col < count($dados)) add_imglink($dados[$i + $col]);
		{
			echo '</tr>';
		}
	}
}	
echo '</table>';
?>

The commas on line 20 should be dots. The curly brackets on lines 36 and 38 serve no purpose.

The commas on line 20 should be dots. The curly brackets on lines 36 and 38 serve no purpose.

It keeps going...

Line 18 is missing an echo. (Turning php tags on and off, doesn't improve the readability.)

Line 18 is missing an echo. (Turning php tags on and off, doesn't improve the readability.)

C'mon i think i'm doing correct now:

function add_imglink($linha) 
{
    echo '<td align="center">';
		while ($row = mysql_fetch_array($executa))
		{ 
          echo  ?> <a href="prog_curso.php?cod= <?PHP echo $row['cod_curso']; ?> "> <?PHP echo $row['nome_curso']; ?> </a>
		<?PHP;}
			  echo '<img src="'. $linha['imagem_curso']. '"><br />';
              echo $linha['nome_curso'];
          echo '</a>';
    echo '</td>';
}

The first echo on line 6 can be removed, and the semi-colon on line 7 too.

also for the link to work remove the space between cod= and <?php

<a href="prog_curso.php?cod=<?PHP echo $row['cod_curso']; ?> ">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.