Jump to content

PHP output to data table


EagleAmerican

Recommended Posts

Here's my add_parasite.php.. it is a parasite database and I need it to output all of the data in the MySQL table into a HTML data table. Right now all of the boxes on the table are the same width and height and I want them to be longer for the description and technical info and shorter for the rest. Please try to make it look good for me.. thanks!!

 

<HTML>
<HEAD>
<META name="GENERATOR" content="WYSIWYG Web Builder from http://www.irishost.net              ">
<TITLE>ParasiteDB - Staff Area - New Parasite</TITLE>
</HEAD>
<BODY bgcolor="#000080" text="#008000">
<IMG src="images/img00002.bmp" width="799" height="77" align="top" style="position:absolute;left:0px;top:0px;width:799px;height:77px;z-index:0">
<DIV style="position:absolute; left:259px; top:76px; width:291px; height:23px; z-index:1"  align="center" valign="top">
<FONT style="FONT-SIZE:14pt" color="#FFFF80" face="Tahoma">Staff Area -> Add New Parasite</FONT></DIV>
<DIV style="position:absolute; left:14px; top:73px; width:150px; height:31px; z-index:2"  align="left" valign="top">
<?php echo 'Hello, <b>Staff</b>.'; ?></DIV>
<DIV style="position:absolute; left:278px; top:132px; width:257px; height:91px; z-index:3"  align="left" valign="top">
<?php if (isset($_GET['addparasite'])): // User wants to add a joke
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Name:<br />
<textarea name="parasitename" rows="1" cols="50">
</textarea></label><br />
<label>From:<br />
<textarea name="parasitefrom" rows="1" cols="50">
</textarea></label><br />
<label>Genre:<br />
<textarea name="parasitegenre" rows="1" cols="50">
</textarea></label><br /
<label>Description:<br />
<textarea name="parasitedescription" rows="5" cols="50">
</textarea></label><br />
<label>Technical Info:<br />
<textarea name="parasitetechinfo" rows="5" cols="50">
</textarea></label><br />
<input type="submit" value="Add" />
</form>

<?php else: // Default page display

$dbcnx = @mysql_connect('mysql3.freehostia.com', 'adaarm_db', 'ppk6g4fdsghd34468n');
if (!$dbcnx) {
   exit('<p>Unable to connect to the ' .
       'database server at this time.</p>');
}

if (!@mysql_select_db('adaarm_db')) {
   exit('<p>Unable to locate the ' .
       'database at this time.</p>');
}

if (isset($_POST['parasitename'])) {
   $parasitename = $_POST['parasitename'];
   $parasitefrom = $_POST['parasitefrom'];
   $parasitegenre = $_POST['parasitegenre'];
   $parasitedescription = $_POST['parasitedescription'];
   $parasitetechinfo = $_POST['parasitetechinfo'];
   $sql = "INSERT INTO parasite SET
       parasitename='$parasitename',
       parasitefrom='$parasitefrom',
       parasitegenre='$parasitegenre',
       parasitedescription='$parasitedescription',
       parasitetechinfo='$parasitetechinfo'";
   if (@mysql_query($sql)) {
     echo "<p>The parasite '$parasitename' has been added.</p>";
   } else {
     echo '<p>Error adding submitted parasite: ' .
         mysql_error() . '</p>';
   }
}

$name = @mysql_query('SELECT parasitename FROM parasite');
if (!$name) {
exit('<p>Error performing query1: ' . mysql_error() . '</p>');
}
$from = @mysql_query('SELECT parasitefrom FROM parasite');
if (!$from) {
exit('<p>Error performing query2: ' . mysql_error() . '</p>');
}
$genre = @mysql_query('SELECT parasitegenre FROM parasite');
if (!$genre) {
exit('<p>Error performing query3: ' . mysql_error() . '</p>');
}
$description = @mysql_query('SELECT parasitedescription FROM parasite');
if (!$description) {
exit('<p>Error performing query4: ' . mysql_error() . '</p>');
}
$techinfo = @mysql_query('SELECT parasitetechinfo FROM parasite');
if (!$techinfo) {
exit('<p>Error performing query5: ' . mysql_error() . '</p>');
}

$sql = mysql_query("SELECT parasitename,parasitefrom,parasitegenre,parasitedescription,parasitetechinfo FROM parasite") or die(mysql_error());
echo '<p>Parasite list:</p>
<TABLE width="100%" height="100%" border="1" cellpadding="2" cellspacing="5"><TR>
<TD align="left" valign="top" width="161">Name</TD>
<TD align="left" valign="top" width="122">From</TD>
<TD align="left" valign="top" width="128">Genre</TD>
<TD align="left" valign="top" width="161">Description</TD>
<TD align="left" valign="top" width="164">Technical Info</TD>
</TR>';

while ($row = mysql_fetch_array($sql)) {
echo '<tr><td align="left" valign="top" width="161">' . $row['parasitename'] . '</td>';
echo '<td align="left" valign="top" width="122">' . $row['parasitefrom'] . '</td>';
echo '<td align="left" valign="top" width="128">' . $row['parasitegenre'] . '</td>';
echo '<td align="left" valign="top" width="161">' . $row['parasitedescription'] . '</td>';
echo '<td align="left" valign="top" width="164">' . $row['parasitetechinfo'] . '</td></tr>';
}

echo '<p><a href="' . $_SERVER['PHP_SELF'] .
     '?addparasite=1">Add a Parasite</a></p>';

endif;
?> </table></DIV>
</BODY>
</HTML>

Link to comment
https://forums.phpfreaks.com/topic/61254-php-output-to-data-table/
Share on other sites

  • 2 weeks later...

Try instead of opening your width sections like <width='600'> Try something like creating a table to hold your entire website and all tables inside use a percentge to stay together! I am tired so dont blame me if my tables script is not right but I believe

 

<table width="600" border="0">

  <tr>

    <td><table width="80%" border="0">

  <tr>

    <td> </td>

  </tr>

</table></td>

  </tr>

  <tr>

    <td><table width="80%" border="0">

  <tr>

    <td> </td>

  </tr>

</table></td>

  </tr>

  <tr>

    <td><table width="80%" border="0">

  <tr>

    <td> </td>

  </tr>

</table></td>

  </tr>

  <tr>

    <td><table width="80%" border="0">

  <tr>

    <td> </td>

  </tr>

</table></td>

  </tr>

  <tr>

    <td><table width="80%" border="0">

  <tr>

    <td> </td>

  </tr>

</table></td>

  </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.