Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Tue Jun 13, 2006 1:59 pm Reply with quote

I am trying to get members to fill my roster and have tried several variations of this but can't get it right.

I want a member to appear on the roster whether or not they have a match in the rank table or weapon table. They must have a unit_id assigned.

Code:
$sql = "SELECT * FROM " . $prefix . "_milpacs_members mm LEFT OUTER JOIN (" . $prefix . "_milpacs_weapons mw) LEFT OUTER JOIN (" . $prefix . "_milpacs_ranks mr) JOIN (" . $prefix . "_milpacs_units mu) ON (mu.unit_id = mm.unit_id AND mw.weapon_id = mm.weapon_id AND mm.rank_id = mr.rank_id AND mm.status IN ('Active','LOA')) ORDER BY mu.unit_order, mm.subunit_id, mr.rank_order, mm.promotion_dt asc";


The reaon for this is if a weapon or rank is deleted I still want the members to appear on the roster so I may go in and edit and set him to another rank or weapon.
[ Only registered users can see links on this board! Get registered or login! ]
 
View user's profile Send private message Visit poster's website ICQ Number
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Tue Jun 13, 2006 9:56 pm Reply with quote

See if this helps you here:
[ Only registered users can see links on this board! Get registered or login! ]

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
Donovan







PostPosted: Wed Jun 14, 2006 8:08 am Reply with quote

But I'm joining 4 different tables together.

milpacs_members
milpacs_weapons
milpacs_units
milpacs_ranks

They must belong to a unit to show on the roster, but need not be assigned a rank or weapon.
 
djmaze
Subject Matter Expert



Joined: May 15, 2004
Posts: 727
Location: http://tinyurl.com/5z8dmv

PostPosted: Wed Jun 14, 2006 9:15 am Reply with quote

SELECT * FROM " . $prefix . "_milpacs_members mm
INNER JOIN (" . $prefix . "_milpacs_units mu) ON (mu.unit_id = mm.unit_id)
LEFT JOIN " . $prefix . "_milpacs_weapons mw ON (mw.weapon_id = mm.weapon_id)
LEFT JOIN " . $prefix . "_milpacs_ranks mr ON (mr.rank_id = mm.rank_id)
WHERE mm.status IN ('Active','LOA')
ORDER BY mu.unit_order, mm.subunit_id, mr.rank_order, mm.promotion_dt asc";
 
View user's profile Send private message Visit poster's website
Donovan







PostPosted: Wed Jun 14, 2006 12:15 pm Reply with quote

Outstanding...
 
Donovan







PostPosted: Wed Jun 14, 2006 12:18 pm Reply with quote

One more quick question.

If there is no weapon assigned and my roster has a hyperlink to the weapon profile such as:

Code:
<a class="content" href="modules.php?name=<?php echo $module_name ?>&amp;file=weaponprofile&amp;weapon_id=<?php echo $weapon_id ?>"><?php echo $make ?></a>


How could I make it not hyperlinked if I went this route?

Code:
if ($row["weapon_id"] =="") {

      $make = "Not Assigned";
   } else {
      $make = "$make";
   }


You follow???

Check it out here.
[ Only registered users can see links on this board! Get registered or login! ]
 
djmaze







PostPosted: Fri Jun 23, 2006 4:29 pm Reply with quote

Code:
if ($row["weapon_id"]) {

    $make = "<a class=\"content\" href=\"modules.php?name=$module_name&amp;file=weaponprofile&amp;weapon_id={$row['weapon_id']}\">$make</a>";
} else {
    $make = "Not Assigned";
}
 
Donovan







PostPosted: Fri Jun 30, 2006 10:03 am Reply with quote

Thanks dj

But I put this in and it doesn't seem to do what is desired.


Here is the block of code in question in my roster.

Code:
<td width='15%' align='center'><?php echo $ri ?></td><td width='30%'>&nbsp;<a class="content" href="modules.php?name=<?php echo $module_name ?>&amp;file=soldierprofile&amp;uniqueid=<?php echo $uniqueid ?>"><?php echo $u_name ?></a>

   </td><td align='center' width='25%'><a class="content" href="modules.php?name=<?php echo $module_name ?>&amp;file=unitprofile&amp;unit_id=<?php echo $unit_id ?>"><?php echo $unitname ?></a></td><td width='25%' align='center'><?php echo $position ?></td><td width='14%' align='center'><a class="content" href="modules.php?name=<?php echo $module_name ?>&amp;file=weaponprofile&amp;weapon_id=<?php echo $weapon_id ?>"><?php echo $make ?></a></td><td width='8%' align='center'><?php echo $status ?></td>


You can see the following

Code:
><a class="content" href="modules.php?name=<?php echo $module_name ?>&amp;file=weaponprofile&amp;weapon_id=<?php echo $weapon_id ?>"><?php echo $make ?></a>


is where the weapon is hyperlinked.

Setting this doesn't effect the way $make is displayed, unless I am missing soemthing here.

Code:
if ($row["weapon_id"]) { 

    $make = "<a class=\"content\" href=\"modules.php?name=$module_name&amp;file=weaponprofile&amp;weapon_id={$row['weapon_id']}\">$make</a>";
   } else {
    $make = "Not Assigned";
   }
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL

View next topic
View previous topic
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 can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©