Current location: Hot Scripts Forums » Programming Languages » PHP » values from drop down menu


values from drop down menu

Reply
  #1 (permalink)  
Old 09-04-06, 04:16 AM
fazzfarrell fazzfarrell is offline
New Member
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
values from drop down menu

I have built a quote generator that now is going to be updated.

This is my code at the moment:
PHP Code:

<select name="Client" id="Client">

                      <?php
do {  
?>
                      <option value="<?php echo $row_rsClient['Client']?>"><?php echo $row_rsClient['Client']?></option>
                      <?php
} while ($row_rsClient mysql_fetch_assoc($rsClient));
  
$rows mysql_num_rows($rsClient);
  if(
$rows 0) {
      
mysql_data_seek($rsClient0);
      
$row_rsClient mysql_fetch_assoc($rsClient);
  }
?>
                    </select>
What I want to do:

The user selects wich client they are quoting for

Then they add hours the job will take then select a, b or c depending on what rate they are charged at

This goes to another page that gives the results, no problem with this it all works but what I nned it to do is:

The clients all have different charge rates so when the client is chosen from the dropdown I want the a, b or c etc to default to the top of the a,b,c menus so the user does not have to keep looking up what rate thay are charged at.

Below the full page code:
PHP Code:

<?php require_once('Connections/grey.php'); ?>

<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

mysql_select_db($database_grey$grey);
$query_rsDesignCost "SELECT * FROM designcosts";
$rsDesignCost mysql_query($query_rsDesignCost$grey) or die(mysql_error());
$row_rsDesignCost mysql_fetch_assoc($rsDesignCost);
$totalRows_rsDesignCost mysql_num_rows($rsDesignCost);

mysql_select_db($database_grey$grey);
$query_rsArtworkCost "SELECT * FROM artworkcost";
$rsArtworkCost mysql_query($query_rsArtworkCost$grey) or die(mysql_error());
$row_rsArtworkCost mysql_fetch_assoc($rsArtworkCost);
$totalRows_rsArtworkCost mysql_num_rows($rsArtworkCost);

mysql_select_db($database_grey$grey);
$query_rsMarkup "SELECT * FROM markup";
$rsMarkup mysql_query($query_rsMarkup$grey) or die(mysql_error());
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
$totalRows_rsMarkup mysql_num_rows($rsMarkup);

mysql_select_db($database_grey$grey);
$query_rsClient "SELECT * FROM ClientCode";
$rsClient mysql_query($query_rsClient$grey) or die(mysql_error());
$row_rsClient mysql_fetch_assoc($rsClient);
$totalRows_rsClient mysql_num_rows($rsClient);
?>
<html>
<head>
<title>Greystone quotation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="grey.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center" valign="top"> 
      <table width="600" border="0" cellspacing="4" cellpadding="0">
        
        <tr> 
          <td><img src="greystone_advertising_logo.jpg" alt="Greystone advertising" width="400" height="49"><br> 
          </td>
        </tr>
        <tr> 
          <td><form name="form1" method="get" action="results.php">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td align="left" valign="middle" class="textMainToptitle"><font color="#999999">Job 
                    Number</font> 
                    <input name="JobNo" type="text" id="JobNo">
                  </td>
                  <td>&nbsp;</td>
                  <td align="right" valign="middle" class="textMainToptitle"><font color="#999999">Client</font>
                    <label>
                    <select name="Client" id="Client">
                      <?php
do {  
?>
                      <option value="<?php echo $row_rsClient['Client']?>"><?php echo $row_rsClient['Client']?></option>
                      <?php
} while ($row_rsClient mysql_fetch_assoc($rsClient));
  
$rows mysql_num_rows($rsClient);
  if(
$rows 0) {
      
mysql_data_seek($rsClient0);
      
$row_rsClient mysql_fetch_assoc($rsClient);
  }
?>
                    </select>
                  </label></td>
                  <td>&nbsp;</td>
                </tr>
                <tr> 
                  <td colspan="4"><table width="100%" border="0" cellspacing="0" cellpadding="4">
                      <tr bgcolor="#999999"> 
                        <td class="textMainTop">Type</td>
                        <td class="textMainTop">Code</td>
                        <td class="textMainTop">Hours/cost</td>
                      </tr>
                      <tr> 
                        <td class="textMain">Design </td>
                        <td><select name="Design" id="Design">
                          <?php
do {  
?><option value="<?php echo $row_rsDesignCost['Cost']?>"<?php if (!(strcmp($row_rsDesignCost['Cost'], $row_rsClient['Design']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsDesignCost['Code']?></option>
                            <?php
} while ($row_rsDesignCost mysql_fetch_assoc($rsDesignCost));
  
$rows mysql_num_rows($rsDesignCost);
  if(
$rows 0) {
      
mysql_data_seek($rsDesignCost0);
      
$row_rsDesignCost mysql_fetch_assoc($rsDesignCost);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="Designhrs" type="text" id="Designhrs" size="10">
                          hrs</td>
                      </tr>
                      <tr> 
                        <td class="textMain">Artwork</td>
                        <td><select name="ArtWork" id="select2">
                          <?php
do {  
?><option value="<?php echo $row_rsArtworkCost['Cost']?>"<?php if (!(strcmp($row_rsArtworkCost['Cost'], $row_rsClient['Artwork']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsArtworkCost['Code']?></option>
                            <?php
} while ($row_rsArtworkCost mysql_fetch_assoc($rsArtworkCost));
  
$rows mysql_num_rows($rsArtworkCost);
  if(
$rows 0) {
      
mysql_data_seek($rsArtworkCost0);
      
$row_rsArtworkCost mysql_fetch_assoc($rsArtworkCost);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="ArtWorkhrs" type="text" id="Designhrs3" size="10">
                          hrs</td>
                      </tr>
                      <tr> 
                        <td class="textMain"><input name="misc1" type="text" id="misc1" size="20"></td>
                        <td><select name="misc1per" id="misc1per">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost1" type="text" id="ArtWorkhrs" size="10">
                          cost</td>
                      </tr>
                      <tr> 
                        <td class="textMain"><input name="misc2" type="text" id="misc2" size="20"></td>
                        <td><select name="misc2per" id="select3">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost2" type="text" id="otherCost" size="10">
                          cost</td>
                      </tr>
                      <tr> 
                        <td><input name="misc3" type="text" id="misc3" size="20"></td>
                        <td><select name="misc3per" id="select4">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost3" type="text" id="otherCost2" size="10">
                          cost</td>
                      </tr>
                      <tr> 
                        <td><input name="misc4" type="text" id="misc4" size="20"></td>
                        <td><select name="misc4per" id="select5">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost4" type="text" id="otherCost4" size="10">
                          cost</td>
                      </tr>
                      <tr> 
                        <td><input name="misc5" type="text" id="misc5" size="20"></td>
                        <td><select name="misc5per" id="select6">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost5" type="text" id="otherCost5" size="10">
                          cost</td>
                      </tr>
                      <tr> 
                        <td><input name="misc6" type="text" id="misc6" size="20"></td>
                        <td><select name="misc6per" id="select7">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost6" type="text" id="otherCost6" size="10">
                          cost</td>
                      </tr>
                      <tr> 
                        <td><input name="misc7" type="text" id="misc7" size="20"></td>
                        <td><select name="misc7per" id="select8">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost7" type="text" id="otherCost7" size="10">
                          cost</td>
                      </tr>
                      <tr> 
                        <td><input name="misc8" type="text" id="misc8" size="20"></td>
                        <td><select name="misc8per" id="select9">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost8" type="text" id="otherCost8" size="10">
                          cost</td>
                      </tr>
                      <tr> 
                        <td><input name="misc9" type="text" id="misc9" size="20"></td>
                        <td><select name="misc9per" id="select10">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost9" type="text" id="otherCost9" size="10">
                          cost</td>
                      </tr>
                      <tr> 
                        <td><input name="misc10" type="text" id="misc10" size="20"></td>
                        <td><select name="misc10per" id="select11">
                            <?php
do {  
?>
                            <option value="<?php echo $row_rsMarkup['percent']?>"><?php echo $row_rsMarkup['Code']?></option>
                            <?php
} while ($row_rsMarkup mysql_fetch_assoc($rsMarkup));
  
$rows mysql_num_rows($rsMarkup);
  if(
$rows 0) {
      
mysql_data_seek($rsMarkup0);
      
$row_rsMarkup mysql_fetch_assoc($rsMarkup);
  }
?>
                          </select></td>
                        <td class="textMain"> <input name="otherCost10" type="text" id="otherCost10" size="10">
                          cost</td>
                      </tr>
                      <tr align="center"> 
                        <td colspan="3"> 
                          <input type="submit" name="Submit" value="Submit">
                        </td>
                      </tr>
                    </table></td>
                </tr>
              </table>
            </form></td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
        </tr>
      </table>
    
    </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result
($rsArtworkCost);

mysql_free_result($rsMarkup);

mysql_free_result($rsClient);
?>

Last edited by nico_swd; 09-04-06 at 04:32 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Auto Dealer Script nuzzle PHP 17 04-14-10 08:34 PM
Xml / Dom / Css Mark_SC.SE JavaScript 0 06-29-05 08:05 AM
Creating a drop down menu ? ? ? Spreegem PHP 4 03-09-05 09:34 AM
Drop Down menu order peterc PHP 1 08-20-04 02:23 AM
drop down menu problem !!! nurqeen PHP 1 02-08-04 08:07 PM


All times are GMT -5. The time now is 07:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.