Jump to content

newbie needing a lot of help.... forms .. var .. mysql ... php


johntigner

Recommended Posts

 

i'm a newbie with PHP and i need help and guide me in the right direction

with this project

 

first if you're familiar with yahoo web hosting they support

phpmyadmin

mysql

 

so anything done will have to work witj yahoo

 

i need to make a quote form that uses two dropdown listboxes and a text box

to access a database with two tables... table and zonerate. the fields are

 

table.. id - code - key - text

zonerate.. zone1 - zone2 - price

 

i can get the listboxes to display the info from table.text and thats about all

after selecting table.text in LISTBOX1....how do store table.code in a var $pzone and

after selecting table.text in LISTBOX2....how do store table.code in a var $dzone?

i was trying the onblur event to set the var

 

from here i need to access zonerate.zone1 and zonerate.zone2 to fine value in zonerate.price

if it exists and display it in TEXTBOX!

 

im using dreamweaver to do this and i noticed that it stores the db connection code in a separate file this is one of those files

 

 

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_zonerate = "localhost";
$database_zonerate = "web_data";
$username_zonerate = "username";
$password_zonerate = "password";
$zonerate = mysql_pconnect($hostname_zonerate, $username_zonerate, $password_zonerate) or trigger_error(mysql_error(),E_USER_ERROR); 
?>

 

**************** this is the code from i need to fix..... i hope someone can help me

 

as you can see i currently have a button to get the price after a selection is made in both listboxes

i prefer not to use a button and hve the price lookup be atuomatic

 

 

 

<?php require_once('Connections/zones.php'); ?>
<?php require_once('Connections/zonerate.php'); ?>
<?php require_once('Connections/quote.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;
}
}

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_zones, $zones);
$query_zones = "SELECT * FROM `table` WHERE id = 'ZN' ORDER BY text ASC";
$zones = mysql_query($query_zones, $zones) or die(mysql_error());
$row_zones = mysql_fetch_assoc($zones);
$totalRows_zones = mysql_num_rows($zones);

mysql_select_db($database_zonerate, $zonerate);
$query_zonerate = "SELECT zonerate.zone1, zonerate.zone2, zonerate.price FROM zonerate ";
$zonerate = mysql_query($query_zonerate, $zonerate) or die(mysql_error());
$row_zonerate = mysql_fetch_assoc($zonerate);
$totalRows_zonerate = mysql_num_rows($zonerate);

mysql_select_db($database_Quote, $Quote);
$query_Quote = "SELECT landmark.name, landmark.stnumber, landmark.staddr, landmark.`zone` FROM landmark";
$Quote = mysql_query($query_Quote, $Quote) or die(mysql_error());
$row_Quote = mysql_fetch_assoc($Quote);
$totalRows_Quote = mysql_num_rows($Quote);
?>]; ?>



<body>



</table> 
<div align="center" class="style3 style5">
  <h1 align="left">Instant Quote</h1>
</div>
    <table width="459" height="122" border="0" bgcolor="#0033FF">
      <tr>
        <td width="193"><div align="center" class="style7">Trip Origin</div></td>
        <td width="46"> </td>
        <td width="198"><div align="center" class="style7">Trip Destination</div></td>
      </tr>
      <tr>
        <td nowrap="nowrap"><form id="form1" name="form1" method="post" action="">
          <label><span class="style10">Address</span>
          <input name="pickstreet" type="text" id="pickstreet" />
          </label>
        </form>        </td>
        <td> </td>
        <td nowrap="nowrap"><form id="form2" name="form1" method="post" action="">
          <strong>
          <label><span class="style8">Address</span>
            <input name="dropstreet" type="text" id="dropstreet" />
          </label>
          </strong>
                                                        </form></td>
      </tr>
      <tr>
        <td><form id="form3" name="form3" method="post" action="">
          <label><span class="style10">City</span>: 
            <select name="pickcity" id="pickcity" onBlur="$pzone = code">
              <?php
do {  
?>
              <option value="<?php echo $row_zones['text']?>"><?php echo $row_zones['text']?></option>
              <?php
} while ($row_zones = mysql_fetch_assoc($zones));
  $rows = mysql_num_rows($zones);
  if($rows > 0) {
      mysql_data_seek($zones, 0);
  $row_zones = mysql_fetch_assoc($zones);
  }
?>
            </select>
            </label>
        </form>        </td>
        <td> </td>
        <td><form id="form4" name="form3" method="post" action="">
          <label><span class="style10">City</span>:  
            <select name="dropcity" id="dropcity" onBlur="$dzone = code">
              <?php
do {  
?>
              <option value="<?php echo $row_zones['text']?>"><?php echo $row_zones['text']?></option>
              <?php
} while ($row_zones = mysql_fetch_assoc($zones));
  $rows = mysql_num_rows($zones);
  if($rows > 0) {
      mysql_data_seek($zones, 0);
  $row_zones = mysql_fetch_assoc($zones);
  }
?>
                                  </select>
          </label>
        </form></td>
      </tr>
      <tr>
        <td valign="top"><div align="right" class="style4 style8">Estimated Cost:</div>
          <form name="form6" method="post" action="">
            <label>getit
              <input name="getit" type="button" id="getit" onClick="do something" value="get it">
            </label>
          </form>
        <p> </p></td>
        <td> </td>
        <td><form id="form5" name="form5" method="post" action="">
          <label>
            <div align="left">
              <input name="price" type="text" id="price" size="7" />
            </div>
          </label>
        </form>        </td>
      </tr>
    </table>





</body>
</html>
<?php
mysql_free_result($zones);

mysql_free_result($zonerate);

mysql_free_result($Quote);
?>

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.