472,133 Members | 1,168 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

Forms updating database

I;m having probs with this script. when i
click update form the values from the text boxs that javascript updates
won't be saved in the data base.
Can any1 help?
Thanks
Kat

<script type="text/javascript">
function ptotal(x,z,r,h,g)
{
var y=document.getElementById(x).value
var d=document.getElementById(z).value
var f=document.getElementById(r).value
document.getElementById(h).value=parseFloat(y*3)+p arseFloat(d)
document.getElementById(g).value=parseFloat(y)+par seFloat(d)+parseFloat(f)
}

function gdtotal(x,z,h)
{
var s=document.getElementById(x).value
var k=document.getElementById(z).value

document.getElementById(h).value=parseFloat(s)-parseFloat(k)
}

</script>
*some code"

<form id="form1" action="admin.php?page=leagueedit" method="post"
enctype="multipart/form-data">

<input type="hidden" name="t_day" value="<?php echo date("d");?>">
<input type="hidden" name="t_month" value="<?php echo date("m");?>">
<input type="hidden" name="t_year" value="<?php echo date("Y");?>">

<?php
while ($row = mysql_fetch_array($numresults)) {
?>
<tr>
<td width="150"><? echo $row{'TEAM'};?></td>

<td><input type="text" size="3" id="<? echo "t_played" . $row{'id'};?>"
name="<? echo "t_played" . $row{'id'};?>" value="<? echo $row{'PLAYED'};?>"
disabled></td>
<td><input type="text" size="3" id="<? echo "t_won" . $row{'id'};?>"
name="<? echo "t_won" . $row{'id'};?>" value="<? echo $row{'WIN'};?>"
onchange="ptotal(this.id,'<? echo "t_draw" . $row{'id'};?>','<? echo
"t_lost" . $row{'id'};?>','<? echo "t_pts" . $row{'id'};?>','<? echo
"t_played" . $row{'id'};?>')"></td>
<td><input type="text" size="3" id="<? echo "t_draw" . $row{'id'};?>"
name="<? echo "t_draw" . $row{'id'};?>" value="<? echo $row{'DRAW'};?>"
onchange="ptotal('<? echo "t_won" . $row{'id'};?>',this.id,'<? echo "t_lost"
.. $row{'id'};?>','<? echo "t_pts" . $row{'id'};?>','<? echo "t_played" .
$row{'id'};?>')"></td>
<td><input type="text" size="3" id="<? echo "t_lost" . $row{'id'};?>"
name="<? echo "t_lost" . $row{'id'};?>" value="<? echo $row{'LOST'};?>"
onchange="ptotal('<? echo "t_won" . $row{'id'};?>','<? echo "t_draw" .
$row{'id'};?>',this.id,'<? echo "t_pts" . $row{'id'};?>','<? echo "t_played"
.. $row{'id'};?>')"></td>
<td><input type="text" size="3" id="<? echo "t_for" . $row{'id'};?>"
name="<? echo "t_for" . $row{'id'};?>" value="<? echo $row{'GFOR'};?>"
onchange="gdtotal(this.id,'<? echo "t_against" . $row{'id'};?>','<? echo
"t_gd" . $row{'id'};?>')"></td>
<td><input type="text" size="3" id="<? echo "t_against" . $row{'id'};?>"
name="<? echo "t_against" . $row{'id'};?>" value="<? echo
$row{'AGAINST'};?>" onchange="gdtotal('<? echo "t_for" .
$row{'id'};?>',this.id,'<? echo "t_gd" . $row{'id'};?>')"></td>

<td><input type="text" size="3" id="<? echo "t_gd" . $row{'id'};?>"
type="text" name="<? echo "t_gd" . $row{'id'};?>" value="<? echo
$row{'GD'};?>" disabled></td>
<td><input type="text" size="3" id="<? echo "t_pts" . $row{'id'};?>"
type="text" name="<? echo "t_pts" . $row{'id'};?>" disabled value="<? echo
$row{'PTS'};?>"></td>
</tr>
<? }?>
</table>

<input type="submit" name="submit" value="Update Table">
</form>

Oct 22 '06 #1
3 3498
Kathryn Gill wrote:
I;m having probs with this script. when i
click update form the values from the text boxs that javascript updates
won't be saved in the data base.
Can any1 help?
Make your software to print out the query you are trying to use, then
make sure that your query is having the correct values. If it is, try
using that query from the mysql command line application and provide
here the query and possible error message and we might help.

If the query doesn't look correct, then the problem is not related to
MySQL and we can't help. You would get better help from javascript of
php related newsgroups in that case.
Oct 22 '06 #2
"Kathryn Gill" <fi*************@hotmail.comwrote in
news:Ns*****************@fe1.news.blueyonder.co.uk :

Hi Kathryn

Where is the PHP code which actually does the insert/update ? As Aggro
suggests echo the actual SQL query and post that so we can see if there is
anything wrong in the query.

In PHP try using mysql_query($qry) or die(mysql_error());

That should print the error out to the screen (assuming you ISP doesn't
have PHP configured to supress such errors/warnings)

Otherwise just echo the result -

if (!mysql_query($sql))
echo "Error: ".mysql_error();

I always echo the query and execute it directly against mysql (using
something like PHPmyAdmin or mySQLFront. Then you can fix any syntax in
the query and get the actual query right and then paste it back in to the
PHP code.

Jody

I;m having probs with this script. when i
click update form the values from the text boxs that javascript
updates won't be saved in the data base.
Can any1 help?
Thanks
Kat
Oct 22 '06 #3
Hi,
I don't seem to get an error, so i'll go to the php forum.
Thanks
Kat

"Jody" <jo**@jcsdynamix.com.auwrote in message
news:Xn*********************************@140.99.99 .130...
"Kathryn Gill" <fi*************@hotmail.comwrote in
news:Ns*****************@fe1.news.blueyonder.co.uk :

Hi Kathryn

Where is the PHP code which actually does the insert/update ? As Aggro
suggests echo the actual SQL query and post that so we can see if there is
anything wrong in the query.

In PHP try using mysql_query($qry) or die(mysql_error());

That should print the error out to the screen (assuming you ISP doesn't
have PHP configured to supress such errors/warnings)

Otherwise just echo the result -

if (!mysql_query($sql))
echo "Error: ".mysql_error();

I always echo the query and execute it directly against mysql (using
something like PHPmyAdmin or mySQLFront. Then you can fix any syntax in
the query and get the actual query right and then paste it back in to the
PHP code.

Jody

>I;m having probs with this script. when i
click update form the values from the text boxs that javascript
updates won't be saved in the data base.
Can any1 help?
Thanks
Kat

Oct 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Test Person | last post: by
2 posts views Thread by Commander Ace | last post: by
5 posts views Thread by fong.yang | last post: by
1 post views Thread by joel | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.