Filling rows in PHP

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Filling rows in PHP
Donovan
CZ Active Member
 Codezwiz Site Donator
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
Another question in general PHP syntax.

I have the following PHP page in a module I am developing and can't seem to find why this page doesn't display the rows. It is a medal page for all the medals and awards listed in my database.

Here is the site.
[ Register or login to view links on this board. ]

Here is the code for this part of the page:

// Header row for table format
  echo"<tr>";
  echo"<td align=\"left\" bgcolor=\"#999999\">";
  echo"<table border=\"1\" cellpadding=\"2\" cellspacing=\"1\" style=\"border-collapse: collapse\" ";
  echo"width=\"100%\" id=\"AutoNumber2\" bordercolor=\"#111111\">";
  echo "<table border=0 width='100%' cellpadding='3'><tr><th width='100%'>3rd ID Medals</th>";
  echo "<table border=0 width='100%' cellpadding='3'><tr><th width='15%'>Image</th><th width='25%'><b>Name</b></th><th width='60%'>Description</th>";
  echo "</tr>";

$sql = "SELECT award_id, award_image, award_name, description FROM roster_awards ORDER BY award_id";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
   extract($row);   
            
$ai = "<img src='modules/MILPACS/images/medals/award_image'>";

// Populate award page from database
  echo"<td width=\"15%\" align=\"left\">$ai</td></td>";
  echo"<td width=\"15%\" align=\"left\">$award_name</td>";
  echo"<td width=\"70%\" align=\"left\">$description</td>";
  echo"</TR>";
           }         
  echo"</BODY>";
  echo"</TABLE>";
  echo""; 
  CloseTable();
  include("footer.php");
  ?>



Back to top Reply with quote
#2   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
Try commenting out the extract function. And using strings.

$ai = $row['ai'];
etc...




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   re: Filling rows in PHP
Donovan
CZ Active Member
 Codezwiz Site Donator
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
Still doesn't like this.


Here is the whole page.


<?php
//////////////////////////////////////////////////////////////////////
//===========================
// MILPACS
//
// This is the Military Personell and Classification System.
//
//
//
///////////////////////////////////////////////////////////////////////

if (!eregi("modules.php", $PHP_SELF)) {
   die ("You can't access this file directly...");
    }
$index=0;
require_once("mainfile.php");
//finds the server's root directory
$self = dirname(__FILE__);
$nukemod = basename($self);
$rootdir = eregi_replace("/modules/$nukemod", "", $self);
global $module_name, $db;
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");

OpenTable();

echo "<style type=\"text/css\">
<!--
/* Info */
p.content      { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #FFFFFF;}
h1 {text-align: center}
-->
</style>";
echo "<table border=0><tr><td width=100%>"
   ."<font class=\"mainroster\"><big><b>3rd Infantry Division Medals</b></big></font><hr width=200 align=\"left\">"
   ."</td></tr></table>";
CloseTable();
$clanmod = "MILPACS";
OpenTable();
//Table layout
echo"<TABLE cellSpacing=0 cellPadding=0 width=650 border=0>";
echo"<BODY>";

echo"<h1><p class=\"content\">The practice of awarding medals to the common soldier started long ago.  The first formal system for rewarding acts of individual gallantry by the nation's fighting men was established by General George Washington on August 7, 1782. Designed to recognize \"any singularly meritorious action,\" the award consisted of a purple cloth heart."
  ."<br>"
  ."<br>"
  . "World War I saw the first Victory Medal and the use of devices such as stars, oak leafs and bars to denote additional awards or campaigns. New decorations were added to maintain the prestige of the Medal of Honor. "
  ."<br>"
  ."<br>"
  . "World War II saw the award system expand to provide a wider degree of decorations for valor and merit and more service medals to signify campaigns in Europe, Asia and the Americas."
  ."<br>"
  ."<br>"
  . "The 3rd Infantry Division continues this time honored tradition of recognizing individual gallantry on the field of battle."
  ."<br>"
."";
echo"</TABLE>";

// Header row for table format
  echo"<tr>";
  echo"<td align=\"left\" bgcolor=\"#999999\">";
  echo"<table border=\"1\" cellpadding=\"2\" cellspacing=\"1\" style=\"border-collapse: collapse\" ";
  echo"width=\"100%\" id=\"AutoNumber2\" bordercolor=\"#111111\">";
  echo "<table border=0 width='100%' cellpadding='3'><tr><th width='100%'>3rd ID Medals</th>";
  echo "<table border=0 width='100%' cellpadding='3'><tr><th width='15%'>Image</th><th width='25%'><b>Name</b></th><th width='60%'>Description</th>";
  echo "</tr>";

$sql = "SELECT award_image, award_name, description FROM roster_awards ORDER BY award_id";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
   //extract($row);   
$ai = $row['award_image'];
$aname = $row['award_name'];
$descr = $row['description'];
            
//$ai = "<img src='modules/MILPACS/images/medals/award_image'>";

// Populate award page from database
  echo"<td width=\"15%\" align=\"left\">$ai</td>";
  echo"<td width=\"15%\" align=\"left\">$aname</td>";
  echo"<td width=\"70%\" align=\"left\">$descr</td>";
  echo"</TR>";
           }         
  echo"</BODY>";
  echo"</TABLE>";
  echo""; 
  CloseTable();
  include("footer.php");
  ?>



Back to top Reply with quote
#4   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
Try this one:


     // Header row for table format
     echo "<tr>";
     echo "<td align=\"left\" bgcolor=\"#999999\">";
     echo "<table border=\"1\" cellpadding=\"2\" cellspacing=\"1\" style=\"border-collapse: collapse\" ";
     echo "width=\"100%\" id=\"AutoNumber2\" bordercolor=\"#111111\">";
     echo "<table border=0 width='100%' cellpadding='3'><tr><th width='100%'>3rd ID Medals</th>";
     echo "<table border=0 width='100%' cellpadding='3'><tr><th width='15%'>Image</th><th width='25%'><b>Name</b></th><th width='60%'>Description</th>";
     echo "</tr>";
     $result = $db->sql_query("SELECT award_image, award_name, description FROM roster_awards ORDER BY award_id");
     while(list($ai, $aname, $desc) = $db->sql_fetchrow($result)) {
     //$ai = "<img src='modules/MILPACS/images/medals/award_image'>";
     // Populate award page from database
     //You forgot a < TR >
     echo "<TR>";
     echo "<td width=\"15%\" align=\"left\">$ai</td>";
     echo "<td width=\"15%\" align=\"left\">$aname</td>";
     echo "<td width=\"70%\" align=\"left\">$descr</td>";
     echo "</TR>";
     }         
     echo "</BODY>";
     echo "</TABLE>";
     CloseTable();
     include("footer.php");


And global $db.



_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#5   re: Filling rows in PHP
Donovan
CZ Active Member
 Codezwiz Site Donator
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
Now have to get my images to show up.



Back to top Reply with quote
#6   re: Filling rows in PHP
Donovan
CZ Active Member
 Codezwiz Site Donator
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
Well made some progress, but images are still not showing up.
[ Register or login to view links on this board. ]

Here is a code snippet for one of the classes of medals. Each one is identical, just different award_class

// Header row for Individual Medal table
     echo "<tr>";
     echo "<td align=\"left\" bgcolor=\"#333333\">";
     echo "<table border=\"1\" cellpadding=\"2\" cellspacing=\"1\" style=\"border-collapse: collapse\" ";
     echo "width=\"100%\" id=\"AutoNumber2\" bordercolor=\"#111111\">";
     echo "<table border=0 width='100%' cellpadding='3'><tr><th width='100%'>Individual Medals</th>";
     echo "<table border=0 width='100%' cellpadding='3'><tr><th width='15%'>Image</th><th width='25%'><b>Name</b></th><th width='60%'>Description</th>";
     echo "</tr>";

     $result = $db->sql_query("SELECT award_image, award_name, award_description, award_class FROM roster_awards WHERE award_class = 'IM' ORDER BY award_id");
     while(list($ai, $aname, $descr) = $db->sql_fetchrow($result)) {
     $ai = "<img src='modules/MILPACS/images/medals/award_image'>";
     // Populate award page from database    
     echo "<TR>";
     echo "<td width=\"20%\" align=\"left\">$ai</td>";
     echo "<td width=\"20%\" align=\"left\">$aname</td>";
     echo "<td width=\"60%\" align=\"left\">$descr</td>";
     echo "</TR>";
     }         
     echo "</BODY>";
     echo "</TABLE>";


Need to get my images to display.


Back to top Reply with quote
#7   re: Filling rows in PHP
Donovan
CZ Active Member
 Codezwiz Site Donator
usa.gif ohio.gif
Occupation: Web Developer
Gender: Male
Fav. Sports Team: St Louis Cardinals
Status: Offline
Joined: Dec 03, 2003
0.02 posts per day
Posts: 160
Points: 9,216
   
Got the last one figured out, now another one for you.

Why wont these display.

. "            <b><font color=\"#000000\">Unit Personnel</font></b>"
  . "         </td>"
  . "      </tr>   <tr>"
  . "      <td align=\"left\" bgcolor=\"#777777\" valign=\"top\" width=\"741\">"
  . "         <table border=\"1\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\" bordercolor=\"#111111\">"
  . "            <tr>"
  . "      <td width=\"13%\">"
  . "         <b><font color=\"#000000\">Rank</font></b>"
  . "      </td>"
  . "      <td width=\"87%\">"
  . "         <b><font color=\"#000000\">Name</font></b>"
  . "      </td>"
  . "   </tr>";
   //returns all units personnel assigned to the chosen platoon
   $unit_id = $_GET['unit_id'];
   $sql = "SELECT rm.u_handle, rm.unit_id, rr.rankname, FROM roster_members rm, roster_ranks rr WHERE rm.unit_id = '$unit_id'";
   $result = $db->sql_query($sql);
   while ( $row = $db->sql_fetchrow($result) ) {
   extract($row);

  echo "   <tr>";
  echo "      <td width=\"13%\">";
  echo "         <b><font color=\"#000000\">$rankname</font></b>";
  echo "      </td>";
  echo "      <td width=\"87%\">";
  echo "         <b><font color=\"#000000\">$u_handle</font></b>";
  echo "      </td>";
  echo "   </tr>";   
   }
  echo "</table>";
  echo "</table>";
  echo "</body>";
  echo "</html>";
CloseTable();
include("footer.php");
?>


It is the last part of my Unit Profile page that lists assigned members.
[ Register or login to view links on this board. ]


Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum