More PHP syntax

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   More PHP syntax
Donovan
CZ Active Member
 Codezwiz Site Donator
Donovan has been a member for over 20 year's 20 Year Member
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
   
I am trying to make a main page for my module that pulls a motd from my roster_main table. It should be rather simple but I can't get this to work.


$sql = "SELECT motd FROM roster_main";
   $result = $db->sql_query($sql);
    $info = $result["$motd"];

echo "<table border=0><tr><td width=600%>";
echo "<font class=\"mainroster\"><big><center><b>MILPACS</b></center></big></font><hr width=600 align=\"center\">";
echo "</td></tr></table>";
echo "<table border=0><tr><td width=600%>";
echo "<big><center><b>$info</b></center></big></td></tr></table>";
CloseTable();
echo "<br>";
include("footer.php");
?>


I plan on adding to this page once I get some content other than the title.
[ Register or login to view links on this board. ]


Back to top Reply with quote
#2   re: More PHP syntax
Gareth
CZ Addict
 Codezwiz Site Donator
Gareth has been a member for over 20 year's 20 Year Member
uk.gif
Occupation: Student, Webmaster
Gender: Male
Fav. Sports Team: Liverpool FC
Status: Offline
Joined: May 29, 2004
0.08 posts per day
Posts: 587
Points: 38,220
   
$sql = "SELECT motd FROM roster_main";
   $result = $db->sql_query($sql);
$row = mysql_fetch_array($result);
    $info = $row["$motd"];

echo "<table border=0><tr><td width=600%>";
echo "<font class=\"mainroster\"><big><center><b>MILPACS</b></center></big></font><hr width=600 align=\"center\">";
echo "</td></tr></table>";
echo "<table border=0><tr><td width=600%>";
echo "<big><center><b>$info</b></center></big></td></tr></table>";
CloseTable();
echo "<br>";
include("footer.php");
?>


it just needed the fetch array icon_biggrin.gif



_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
#3   re: More PHP syntax
Donovan
CZ Active Member
 Codezwiz Site Donator
Donovan has been a member for over 20 year's 20 Year Member
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
   
Thanks for the quick reply, but it still isn't pulling anything from the roster_main. I made the motd field a blob since it has a paragraph of text in it.

You can see the result here.
[ Register or login to view links on this board. ]

Nothing is displayed.

Edit... Nevermind

I found I had to take out the "" surrounding motd. Now it works.

$sql = "SELECT motd FROM roster_main";
$result = $db->sql_query($sql);
$row = mysql_fetch_array($result);
$info = $row["motd"];



Back to top Reply with quote
#4   re: More PHP syntax
Gareth
CZ Addict
 Codezwiz Site Donator
Gareth has been a member for over 20 year's 20 Year Member
uk.gif
Occupation: Student, Webmaster
Gender: Male
Fav. Sports Team: Liverpool FC
Status: Offline
Joined: May 29, 2004
0.08 posts per day
Posts: 587
Points: 38,220
   
YW, Didnt really know it was quick, just came online and saw a PHP question, i like answering PHP questions lol icon_razz.gif

Gareth




_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
#5   re: More PHP syntax
Donovan
CZ Active Member
 Codezwiz Site Donator
Donovan has been a member for over 20 year's 20 Year Member
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 then stick around, I'll have a million of them. icon_biggrin.gif



Back to top Reply with quote
#6   
Gareth
CZ Addict
 Codezwiz Site Donator
Gareth has been a member for over 20 year's 20 Year Member
uk.gif
Occupation: Student, Webmaster
Gender: Male
Fav. Sports Team: Liverpool FC
Status: Offline
Joined: May 29, 2004
0.08 posts per day
Posts: 587
Points: 38,220
   
lol, i check here every day dont worry icon_biggrin.gif




_________________
[ Register or login to view links on this board.]
Back to top Reply with quote
#7   re: More PHP syntax
Donovan
CZ Active Member
 Codezwiz Site Donator
Donovan has been a member for over 20 year's 20 Year Member
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
   
Here is one for you.

With the following code I am able to pull records from an award_lkup table. The award_lkup is because I had a many to many relationship between roster_awards and roster_members.

The thing that is in error is that I am pulling all records in the award_lkup table. Even the ones that a member doesn't have.
[ Register or login to view links on this board. ]

Here is my code.


$result3 = $db->sql_query("SELECT * FROM roster_awards a JOIN award_lkup b JOIN roster_members c WHERE b.uniqueid = c.uniqueid AND a.award_id = b.award_id");
   while ( $row = $db->sql_fetchrow($result3) ) {
      $aname = $row["award_name"];
      $adetail = $row["award_decription"];
      $adate = $row["award_dt"];
        if (!$result3) {
          echo("<p>Error performing query: " . mysql_error() . "</p>");
          exit();    }
       
  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"<tr>";
  echo"<td width=\"11%\" valign=\"top\" align=\"left\">$adate";
  echo"</td>";
  echo"<td width=\"89%\" valign=\"top\" align=\"left\">$aname $adetail</td>";   
  echo"</table>";   
  echo"</td>";   
  echo"</tr>";
   }
  echo"</table>";
  echo"</body>";
  echo"</html>";
  CloseTable();
  include("footer.php");
  ?>


I have some tougher ones than this.. icon_sad.gif


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