Printing Table with PHP
Moderator: General Moderators
Printing Table with PHP
I need help creating a table with the PHP function echo, and printing variables in the same statement.
Here's what I have:
echo("<tabel>");
echo("<tr>");
echo("<td WIDTH=400>$row['title'] Seller: $row['name']</td>");
echo("</tr>");
I have tried several different ways to print this, so this is my original code.
Foxy
Here's what I have:
echo("<tabel>");
echo("<tr>");
echo("<td WIDTH=400>$row['title'] Seller: $row['name']</td>");
echo("</tr>");
I have tried several different ways to print this, so this is my original code.
Foxy
Re: Printing Table with PHP
Code: Select all
echo "<table>";
echo "<tr>";
echo "<td width=400>".$row['title']." Seller: ".$row['name']."</td>";
echo("</tr>");
Re: Printing Table with PHP
That worked, but it isn't printing the database values on the page, in the array $row.php_east wrote:Code: Select all
echo "<table>"; echo "<tr>"; echo "<td width=400>".$row['title']." Seller: ".$row['name']."</td>"; echo("</tr>");
Re: Printing Table with PHP
that would be a problem before this part, inside or after your database.
Re: Printing Table with PHP
This is what I have:
$con = mysql_connect("localhost", "yourcol1_default", "default");
if(!$con)
{
die('Cannot connect: ' .mysql_error());
}
mysql_select_db("yourcol1_ITEM", $con);
$query = "SELECT * FROM SELL";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
It was printing the values of the database before I decided to create tables.
Foxy
$con = mysql_connect("localhost", "yourcol1_default", "default");
if(!$con)
{
die('Cannot connect: ' .mysql_error());
}
mysql_select_db("yourcol1_ITEM", $con);
$query = "SELECT * FROM SELL";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
It was printing the values of the database before I decided to create tables.
Foxy
Re: Printing Table with PHP
which means at this point, before entry into the table, you would haveFoxy999 wrote:It was printing the values of the database before I decided to create tables.Foxy
$row values. but when you entered the table, you did not repeat this, hence you will not have any $rows.
Code: Select all
while($row = mysql_fetch_array($result))
{
TABLE SHOULD BE HERE ( you may also wish to confirm first you have $row by printing just $row. )
}
Re: Printing Table with PHP
I am not sure if I understand; there are values in the database so something should show up. My while loop is working and it is printing the table and some words as many times as there are data in the database.php_east wrote:which means at this point, before entry into the table, you would haveFoxy999 wrote:It was printing the values of the database before I decided to create tables.Foxy
$row values. but when you entered the table, you did not repeat this, hence you will not have any $rows.
also, please use the codes tag provided in this forum, it makes reading codes a lot easier.Code: Select all
while($row = mysql_fetch_array($result)) { TABLE SHOULD BE HERE ( you may also wish to confirm first you have $row by printing just $row. ) }
Re: Printing Table with PHP
I am still having trouble with values from the database not showing up in the tables, please help.
Note: See above post.
Note: See above post.
Re: Printing Table with PHP
Nevermind, I got it to work.