Ravens PHP Scripts: Forums
 

 

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



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

PostPosted: Mon May 22, 2006 12:08 pm Reply with quote

Getting back into the coding groove after a break.

I need to populate a combo box and have the following code.

Code:
// Load Divisions (Allied or Axis)

$divselecthtml = "<select name=\"div_id\">";
$divselecthtml .= "<option value=\"\">Select Army</option>";
$result2 = $db->sql_query("SELECT * FROM " . $prefix . "_eto_divisions order by div_name");
while ($divrow = $db->sql_fetchrow($result2)) {
   if ($divrow[div_id]==$div_id) {
      $divselecthtml .= "<option value =\"$divrow[div_id]\" selected>$divrow[div_name]</option>";
   } else {
      $divselecthtml .= "<option value =\"$divrow[div_id]\" >$divrow[div_name]</option>";
   }
}
$divselecthtml .= "</select>";


A unit is either "Allied" with a div_id of 1, or "Axis" with a div_id of 2, or "Unassigned" with a div_id of 3.

I need to pull the value of their current div_id and update the table with an Update statement.

The combo box is displayed but it doesn't show the currrent value.
 
View user's profile Send private message Visit poster's website ICQ Number
Donovan







PostPosted: Mon May 22, 2006 12:15 pm Reply with quote

I also have this simple one

Code:
<SELECT name="div_id">

<OPTION value="1">Allied</OPTION>
<OPTION value="2">Axis</OPTION>
<OPTION value="3">Unassigned</OPTION>
</SELECT>
 
Donovan







PostPosted: Mon May 22, 2006 2:57 pm Reply with quote

Got it working.


Code:
<select name="div_id" size="1">

      <option value="">--- Select Division ---</option>
<?php
$result = $db->sql_query("SELECT * FROM " . $prefix . "_tc_teams tct JOIN " . $prefix . "_eto_divisions ed WHERE tct.div_id = ed.div_id AND tct.team_id ='$id'");
while ( $row = $db->sql_fetchrow($result) ) {
   $div_name = $row["div_name"];
   $div_id = $row["div_id"];
   if ($div_id == $div_id) {
      echo "<option selected value='$div_id'>$div_name</option>";
   } else {
      echo "<option value='$div_id'>$div_name</option>";
   }
}
?>
      </select>
 
montego
Site Admin



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

PostPosted: Mon May 22, 2006 8:05 pm Reply with quote

Just saw this! Way to go Donovan!

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

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 ©