Jump to content

Table with Connection MySQL DataBase


PF2G

Recommended Posts

Hello, PHPFreaks

 

I'm creating a website about a Music School and i want to create a table with the instruments one row with image and a row bellow with their name.

 

<table width="200" height="134">
<?PHP

//connect database
$dbhost = "";
$db = "";
$dbuser = "";
$dbpass = "";
$connect = mysql_connect($dbhost,$dbuser,$dbpass) or die ("Falha ao ligar à Base de Bados: " . mysql_error());

//3 columns limit
i == 3;
while {
i == i + 1;
if i == 1 {
?>
<tr>
<td>

<?PHP  
}  else  
{
?>
<td>

<?    
}
$sql = "SELECT nome_curso, imagem_curso FROM cursos ORDER BY nome_curso";
}
if i == 3 {
?>
</td>
</tr>

<? 
}else
{
?>
</td>

<?PHP
}?>
</table> ()

 

 

 

The name and the image are in a MySQL DB.

 

Please help me.

 

Thank You

Link to comment
https://forums.phpfreaks.com/topic/249719-table-with-connection-mysql-database/
Share on other sites

<?php

$s = "SELECT nome_curso, imagem_curso FROM cursos ORDER BY nome_curso";
$r =  mysql_query($s);
$n =  mysql_num_rows($r);

if($n !=0)
{
	echo"<table width='750' border='1' cellspacing='0' cellpadding='1'><tr>";
	while($row = mysql_fetch_assoc($r))
	{

    		echo "<td>". $row['nome_curso']."</td>";
    		echo "<td><img src='imagepath/images/". $row['imagem_curso'] ." ></td>";
	}
		echo "</tr></table>";

}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.