Jump to content

Need this php code displayed like this table


tracy

Recommended Posts

I have a display page that echoes a table.  I'd like to change the format of the table.  This is the table I'd like to have it display, with the appropriate "$whatever" in each cell...

<div align="center">
  <center>
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="600">
    <tr>
      <td>
      <div align="center">
        <center>
        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
          <tr>
            <td width="100%">
            <div align="center">
              <center>
              <table border="0" cellpadding="3" cellspacing="3" style="border-collapse: collapse" bordercolor="#111111" width="100%">
                <tr>
                  <td width="16%" align="center">".$photo1."</td>
                  <td width="16%" align="center">".$photo2."</td>
                  <td width="17%" align="center">".$photo3."</td>
                  <td width="17%" align="center">".$photo4."</td>
                  <td width="17%" align="center">".$photo5."</td>
                  <td width="17%" align="center">".$photo6."</td>
                </tr>
              </table>
              </center>
            </div>
            </td>
          </tr>
          <tr>
            <td width="100%">
            <div align="center">
              <center>
              <table border="0" cellpadding="3" cellspacing="3" style="border-collapse: collapse" bordercolor="#111111" width="100%">
                <tr>
                  <td width="33%" align="center">".$stock."</td>
                  <td width="33%" align="center">".$year."</td>
                  <td width="34%" align="center">".$make."</td>
                </tr>
                <tr>
                  <td width="33%" align="center">".$model."</td>
                  <td width="33%" align="center">".$price."</td>
                  <td width="34%" align="center">".$miles."</td>
                </tr>
              </table>
              </center>
            </div>
            </td>
          </tr>
        </table>
        </center>
      </div>
      </td>
    </tr>
  </table>
  </center>
</div>


Here is the current php code...

<?php
include('link.php');
// Link to thumbnail images in reference to where this page is
$thumb_path = "thumbs"; // this will be in a thumbs folder in the same directory as this file
// Link to full size images in reference to where this page is
$full_path =  "."; // this would mean the full size images are in this same folder

$query= mysql_query("SELECT * FROM inventory") or die("ERROR:" . mysql_error());



$num = mysql_num_rows($query);

if ($num == '0') {
echo "No Data To Display In This Database.";
die();
}
else {

?>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<td><font face=Arial></font>
</td>
<td><font face=Arial></font>
</td>
<td><font face=Arial></font>
</td>
<td><font face=Arial></font>
</td>
<td><font face=Arial></font>
</td>
<td><font face=Arial></font>
</td>
<td><font face=Arial></font>
</td>
<td><font face=Arial></font>
</td>
</tr>
<?php
while ($info = mysql_fetch_array($query)) {
$stock = $info['stock'];
$year = $info['year'];
$make = $info['make'];
$model = $info['model'];
$price = $info['price'];
$miles = $info['miles'];
if($info['photo1'] == NULL){
$photo1 = "[No image]";
} else {
$photo1 = "<a href=\"".$full_path."/".$info['photo1']."\"><img src=\"".$thumb_path."/".$info['photo1']."\"></a>";
}
if($info['photo2'] == NULL){
$photo2 = "[No image]";
} else {
$photo2 = "<a href=\"".$full_path."/".$info['photo2']."\"><img src=\"".$thumb_path."/".$info['photo2']."\"></a>";
}
echo "
<tr>
<td> <font face=Arial>".$stock."</font>
</td>
<td> <font face=Arial>".$year."</font>
</td>
<td> <font face=Arial>".$make."</font>
</td>
<td> <font face=Arial>".$model."</font>
</td>
<td> <font face=Arial>".$price."</font>
</td>
<td> <font face=Arial>".$miles."</font>
</td>
<td> <font face=Arial>".$photo1."</font>
</td>
<td> <font face=Arial>".$photo2."</font>
</td>
<td> <font face=Arial>".$photo3."</font>
</td>
<td> <font face=Arial>".$photo4."</font>
</td>
<td> <font face=Arial>".$photo5."</font>
</td>
<td> <font face=Arial>".$photo6."</font>
</td>
</tr>
";

}
?>
</table>
<?php
}
?>

Any advice is appreciated.  I tried to change the table but it keeps getting errors.  I think I might have to put each php command in each cell, but don't know how.  Thanks.
Link to comment
Share on other sites

Thanks for the attitude...NOT!  I don't know anything about tags...I'm learning!!! 


[quote author=Crayon Violent link=topic=119588.msg489951#msg489951 date=1166753007]
care to explain what kind of errors you are getting? or what you mean by "I want to 'change the format' of the table?" Change it to what? And also can you please show at least a small amount of respect by using code tags.
[/quote]
Link to comment
Share on other sites

When you are posting snippets of your code enclose it in the code tags, if you look at the buttons when you are posting you should be able to find it.

Also, what is it that you want to change with this table? Is it not echoing correctly? Are the variables not being printed?
Link to comment
Share on other sites

Thanks for the kind info...

I cut and paste the table I want into the php code table near the bottom of the php code after echo "...

I get errors like unexpected / or that it actually expected a "," or ";"

Then I take out that line, and the next until I get the error gone...

Then, obviously the table doesn't echo correctly...

I think I'm going to have to put the individual php commands in the cells for each time I want to call info into that cell, but in a complicated php code like this I don't know if that would even work, let alone how to start...

The php basically prints each line in the database on a line of its own now...fine.
I want the info printed in a way that sort of pieces it together in a table within a table...as the table in the first of the post.

Any info is appreciated.

[quote author=jcbarr link=topic=119588.msg489956#msg489956 date=1166754262]
When you are posting snippets of your code enclose it in the code tags, if you look at the buttons when you are posting you should be able to find it.

Also, what is it that you want to change with this table? Is it not echoing correctly? Are the variables not being printed?
[/quote]
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.