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
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>";

}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • 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.