Some help with PHP

Status
Not open for further replies.

Kd_91

New Member
Messages
7
Reaction score
0
Points
0
Hey guys,

Well I've been working on my fan site a lot lately, but I have run into a problem.

I want the site to display info about in-game items in a table. I have entered all the data to go in the table in a MySQL database. Then I used PHP to enter the data into my table. Works perfect, except.... I need to make the table look nice, but if I try to add things like align="center" into the <td> tag, it gets messed up by the quotes because I am using the echo function to write the tables.

http://kd91.x10hosting.com/rappelz/page2.php <- My tables with info

And here's a snippet of my code to help communicate what I am talking about:

PHP:
<?php
  $result = mysql_query(
            "SELECT * FROM weapons WHERE weap_id='1'");
            
  if (!$result) {
    echo("<P>Error performing query: " .
         mysql_error() . "</P>");
    exit();
  }
  while ( $row = mysql_fetch_array($result) ) {

echo "<tr>";
echo "<td><div>1</div></td>";
echo "<td><div>".$row['weap_1patck']."</div></td>";
echo "<td><div>".$row['weap_1matck']."</div></td>";
echo "<td><div>".$row['weap_1spd']."</div></td>";
echo "<td><div>".$row['weap_1cost']."</div></td>";
echo "</tr>";
echo "<tr>";
See how if I add the align="center" to the <div> tag that it would mess up the echo?

Is there a way for me to do things like center the data and change the properties of the table cell?
 

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
You can escape " by using back-slash before it.

For example:
PHP:
echo "<td align=\"center\">" . $data . "</td>";
 
Status
Not open for further replies.
Top