Click here to get back home

Forms updating database

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Forms updating database Kathryn Gill 10-22-2006
Get Chitika Premium
Posted by Kathryn Gill on October 22, 2006, 11:52 am
Please log in for more thread options
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)+parseFloat(d)
document.getElementById(g).value=parseFloat(y)+parseFloat(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;?></td>

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

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

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




Posted by Aggro on October 22, 2006, 6:20 pm
Please log in for more thread options
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.

Posted by Jody on October 22, 2006, 6:38 pm
Please log in for more thread options

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
>

Posted by Kathryn Gill on October 23, 2006, 8:55 am
Please log in for more thread options
Hi,
I don't seem to get an error, so i'll go to the php forum.
Thanks
Kat

>
> 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
>>



Similar ThreadsPosted
updating old query? August 16, 2006, 11:09 am
Updating a JOINed recordset March 1, 2006, 12:56 am
Updating Column Descriptions (Comments) December 15, 2005, 3:11 pm
Partially updating records based on pattern match October 5, 2005, 1:33 am
converting ms access database to mysql 5 database March 13, 2006, 5:33 pm
Two way syncronizing with a website database with a local database February 4, 2007, 4:34 pm
how to convert .dbf database to mysql database May 13, 2007, 7:09 am
I need to move column field values from one database table to another database table January 27, 2006, 1:15 pm
Same database name October 27, 2006, 3:10 pm
Same database name October 27, 2006, 3:32 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap