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

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.