logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 09-03-2014, 02:21 AM   #1
L.O.F.T.
 
Join Date: Sep 2014
Posts: 2
Default Submit a Repeat Region to Database

Hello Experts,

Usually I can find my answers through searching online but I have failed tonight. I am pulling data out of a database and displaying within a repeat region table. Within the mysql query I am performing some additional calculations with the database information and displaying AS "new fields".

I can see all the appropriate information in my table. My question is: Can I submit the entire region back into a database table? I tried it out and got nothing but null values. However, I am not sure if it is possible or not.

Thank you for any information you can provide.

L.O.F.T
L.O.F.T. is offline   Reply With Quote
Old 09-03-2014, 03:08 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

yes you can but the info is a little vague on what you are doing and what calculation you are applying.
just a stab in the dark , an example thta might help
Code:
$row['price'];
$newprice =$row['price']*$row['tax'];
the new value $newprice is multiplied by tax and can now be entered onto a database.

no expert, but i used to be pert but now im not
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is online now   Reply With Quote
Old 09-04-2014, 12:37 AM   #3
L.O.F.T.
 
Join Date: Sep 2014
Posts: 2
Default Submit a Repeat Region to Database

A little more specifics. I have as SQL query that works:

Quote:
mysql_select_db($database_workrelated, $workrelated);
$query_RSWeek1Calc = "SELECT game_data.Username, ABS(game_data.Team1_SCR- 52) + ABS(game_data.Team2_SCR -14) AS OFFSET1, ABS(game_data.Team3_SCR - 34) + ABS(game_data.Team4_SCR -43) AS OFFSET2, ABS(game_data.Team1_SCR- 52) + ABS(game_data.Team2_SCR -14) + ABS(game_data.Team3_SCR - 34) + ABS(game_data.Team4_SCR -43) AS TOTAL, game_data.Team1_SCR, game_data.Team2_SCR, game_data.Team3_SCR, game_data.Team4_SCR FROM game_data WHERE Week = 1 AND Season = 1 ORDER BY TOTAL ";
$RSWeek1Calc = mysql_query($query_RSWeek1Calc, $workrelated) or die(mysql_error());
$row_RSWeek1Calc = mysql_fetch_assoc($RSWeek1Calc);
$totalRows_RSWeek1Calc = mysql_num_rows($RSWeek1Calc);
Then I have a Form i Created with a repeating Table that works:

Quote:
<form method="POST" action="<?php echo $editFormAction; ?>" name="form"><?php do { ?>
<table align="center" border="1" >
<tbody style="text-align: center">
<tr align="center" >
<td width="225" scope="col"><?php echo $row_RSWeek1Calc['Username']; ?></td>
<td width="100" scope="col" ><?php echo $row_RSWeek1Calc['Team1_SCR']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['Team2_SCR']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['Team3_SCR']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['Team4_SCR']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['OFFSET1']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['OFFSET2']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['TOTAL']; ?></td>
</tr>
</tbody>
</table>
<?php } while ($row_RSWeek1Calc = mysql_fetch_assoc($RSWeek1Calc)); ?><input type="submit"><input name="offset1" type="hidden" id="offset1" value="<?php echo $row_RSWeek1Calc['OFFSET1']; ?>"><input name="offset2" type="hidden" id="offset2" value="<?php echo $row_RSWeek1Calc['OFFSET2']; ?>"><input name="total" type="hidden" id="total" value="<?php echo $row_RSWeek1Calc['TOTAL']; ?>"><input name="correctPicks" type="hidden" id="correctPicks" value="<?php echo $row_rsAdmin['']; ?>"><input name="Pts" type="hidden" id="Pts" value="10">
<input type="hidden" name="MM_insert" value="form">
<input name="username" type="hidden" id="username" value="<?php echo $row_RSWeek1Calc['Username']; ?>">
<input name="scr1" type="hidden" id="scr1" value="<?php echo $row_RSWeek1Calc['Team1_SCR']; ?>">
<input name="scr2" type="hidden" id="scr2" value="<?php echo $row_RSWeek1Calc['Team2_SCR']; ?>">
<input name="scr4" type="hidden" id="scr4" value="<?php echo $row_RSWeek1Calc['Team4_SCR']; ?>">
<input name="week" type="hidden" id="week" value="1">
<input name="season" type="hidden" id="season" value="1">
<input name="email" type="hidden" id="email" value="<?php echo $row_rsAdmin['Email']; ?>">
<input name="locked" type="hidden" id="locked" value="YES">
</form>
I am attempting to echo all the returned results and submit all the fields to another Table in the database. But although I can see the whole table, I get "null" values on the above. I believe this is not a abnormal thing to want to do and it is probably simple...but I am currently unsuccessful.

This is the code on the Submit button:

Quote:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
$insertSQL = sprintf("INSERT INTO game_calc (UserID, Username, Season, Week, Team1_SCR, Team2_SCR, Team3_SCR, Team4_SCR, Game1_OFFSET, Game2_OFFSET, `Total OFFSET`, `Correct Picks`, `PTS EARNED`, Locked) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['season'], "int"),
GetSQLValueString($_POST['week'], "int"),
GetSQLValueString($_POST['scr1'], "int"),
GetSQLValueString($_POST['scr2'], "int"),
GetSQLValueString($_POST['scr3'], "int"),
GetSQLValueString($_POST['scr4'], "int"),
GetSQLValueString($_POST['offset1'], "int"),
GetSQLValueString($_POST['offset1'], "int"),
GetSQLValueString($_POST['total'], "int"),
GetSQLValueString($_POST['correctPicks'], "int"),
GetSQLValueString($_POST['Pts'], "int"),
GetSQLValueString($_POST['locked'], "text"));

mysql_select_db($database_workrelated, $workrelated);
$Result1 = mysql_query($insertSQL, $workrelated) or die(mysql_error());
}
L.O.F.T. is offline   Reply With Quote
Reply


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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:49 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com