Click to See Complete Forum and Search --> : Passing Data


focus310
02-06-2007, 08:23 AM
Hello:

I have the following scenario. An employee will enter their username and password and will be brought to an admin page.

On the admin page, there is a main menu. On the main menu, I have the following links: 30yr, 15yr, 5/1 ARM, 3/1 ARM. When she clicks, let's say, 30yr, it will bring her to a data entry form where she will the days new rates. When she completes the 30yr she clicks update, the table is updated, and is brought back to the main menu. At the main menu, she would select the 15yr and enter the rates and update. This would repeat for all programs.

I would like to have one data entry form for all the links not a seperate form each link. The form has to pass the rate information into a table along with the program which the rates are representing. Otherwise, I have a table with rates and not know which rate belongs to which program.

Does anyone have an idea what I can do to select the program I want, enter the rates for that program, and store both the rates and program into a table then be able to return to the main menu and select the next program and do the whole process over again?

Any help is greatly appreciated. Thank you.

cjc1055
02-06-2007, 09:51 AM
Why can't you just combine it to one form?

If you post your code for one of your forms that would be a lot of help, but without seeing your code try something like this. Assuming your using mysql.

<form methond="post">
Enter new 30 Year Rate<iput type="text" name="30yrnewrate">
Enter new 15 Year Rate<iput type="text" name="15yrnewrate">
</form>

$conn = mysql_connect('host', 'user', 'pass') or die ('Error connecting to mysql');
mysql_select_db('database');
$query1 = "UPDATE rates SET currentrate='$_POST('30yrnewrate') WHERE type='30yr'";
$query2="UPDATE rates SET currentrate=$_POST('15yrnewrate') WHERE type='15yr'";
mysql_query($query1);
mysql_query($query2);

It all depends on how your table is set up in your databse.

focus310
02-06-2007, 10:01 AM
Hello:

Your idea would probably work if I only need to enter one rate for each program.

We need to enter 10 rates for each program. In this case we have three programs each with 10 rates for a total of 30 rates to be entered and updated.

cjc1055
02-06-2007, 10:21 AM
then instead of
$query1 = "UPDATE rates SET currentrate='$_POST('30yrnewrate') WHERE type='30yr'";
use this:

$query1 = "UPDATE rates SET currentrate='$_POST('30yrnewrate') AND secondvariable='$_POST('secondvariable') AND thirdvariable='$_POST('thirdvariable') WHERE type='30yr'";

focus310
02-07-2007, 09:54 AM
Hello:

I'll referring to your revised query statement you wrote:

$query1 = "UPDATE rates SET currentrate='$_POST('30yrnewrate') AND secondvariable='$_POST('secondvariable') AND thirdvariable='$_POST('thirdvariable') WHERE type='30yr'";

Based on the above, my form would look something like this:

<form methond="post">
1st 30 Year Rate<iput type="text" name="30yrnewrate">
2nd 30 Year Rate<iput type="text" name="secondvariable">
3rd 30 Year Rate<input type="text" name="thirdvariable">
etc......(I would have up to ten variables because each program will have 10 rates entered).
</form>

Am I correct so far?

Now, if I use this approach how will my database table appear? Will my table have the fields as: id | rate |
or
will the table have the fields as: id | 30yrnewrate | secondvariable | thirdvariable?

I need my table to appear like this:
id | mortgage_type_id | rate | price
where each mortgage_type_id will have 10 rows.

The mortgage_type_id comes from a lookup table.

Going back to your revised line of code, will that allow me to update the table in the structure that is in red?

Thank you for the help.

cjc1055
02-07-2007, 10:43 AM
Without knowing more about what exactly your looking to do, this is the best I can do based on my interpretation. You'll have to edit this to fit your exact situation, but it should work.


<form method="post">
1st 30 Year Rate<input type="text" name="30yrrate">
1st 30 Year Price<input type="text" name="30yrprice">

1st 15 Year Rate<input type="text" name="15yrrate">
2nd 15 Year Price<input type="text" name="15yrprice">


</form>



<?
$query1 = "UPDATE rates SET rate='$_POST('30yrrate') AND price='$_POST('30yrprice') WHERE mortgage_type_id='30yr_conv'";
$query2 = "UPDATE rates SET rate='$_POST('15yrrate') AND price='$_POST('15yrprice') WHERE mortgage_type_id='15yr_conv'";
?>


Or better yet, you can get the "id" of the text your editing, then update by id...

example:
<?

if(isset($_POST['submit'])) {

$query="UPDATE zibapass SET rate='$ud_rate', price='$ud_price' WHERE `mortgage_rate_id`='$ud_mortage_rate_id'";
@mysql_select_db('rate') or die( "Unable to select database");
mysql_query($query);
echo "<p>Record Updated</p>";
mysql_close();
}




$query="SELECT * FROM rate ORDER BY mortgage_id_rate ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();

$i=0;
while ($i < $num) {

$id=mysql_result($result,$i,"id");
$mortgage_rate_id=mysql_result($result,$i,"mortgage_rate_id");
$rate=mysql_result($result,$i,"rate");
$price=mysql_result($result,$i,"price");

?>


<form method="post">
<input type="hidden" name="ud_id" value="<? echo "$id"; ?>">
<input type="hidden" name="ud_mortgage_rate_id" value="<? echo "$mortgage_rate_id"; ?>">
Rate: <input type="text" name="ud_rate" value="<? echo "$rate" ?>"><br>
Price: <input type="text" name="ud_price" value="<? echo "$price" ?>"><br>
<input type="Submit" name="submit" value="Update"><input type="submit" name="Delete" Value="Delete Record">
</form>

focus310
02-07-2007, 07:49 PM
Hello:

Thank you for the reply. I think I see where you are going with both options. I'll give it a try to fit my situation. Hopefully, it will work.

Thanks again.