Hi
I need to update one table. I have one grid and I want to refresh my webpage after updating the table. I use a form and what i have to write in action of that form?
Thank you
Update Table
Moderator: General Moderators
Re: Update Table
Can you please post up your form?
Last edited by aravona on Tue Jan 12, 2010 7:26 am, edited 1 time in total.
-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Re: Update Table
Here is my code
<?php
$mysql_id = mysql_connect('localhost', 'curso', '123');
mysql_select_db('vendas',$mysql_id);
$query='Select * from noite';
$result=mysql_query($query);
?>
/*construçao da tabela */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<table border="1">
<?php
while($row=mysql_fetch_array($result)){
?>
<tr>
<td><?php print $row['Nome'];?></td>
<td><?php print $row['Idade'];?></td>
</tr>
<?php
}
?>
</table>
<form action="selecciona.php" method="get">
<p><input type="text" name="Idade"/></p>
<p><input type="submit" value="Enviar!" /></p>
</form>
</html>
I need to update the field idade in my table
Thank you
<?php
$mysql_id = mysql_connect('localhost', 'curso', '123');
mysql_select_db('vendas',$mysql_id);
$query='Select * from noite';
$result=mysql_query($query);
?>
/*construçao da tabela */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<table border="1">
<?php
while($row=mysql_fetch_array($result)){
?>
<tr>
<td><?php print $row['Nome'];?></td>
<td><?php print $row['Idade'];?></td>
</tr>
<?php
}
?>
</table>
<form action="selecciona.php" method="get">
<p><input type="text" name="Idade"/></p>
<p><input type="submit" value="Enviar!" /></p>
</form>
</html>
I need to update the field idade in my table
Thank you
Re: Update Table
Ok your sending your data to the selecciona.php?
If you want to update your table in your database using this form you need to use something like
about updating
If you want to update your table in your database using this form you need to use something like
Code: Select all
update [table name] where [field] = [what you want to update it with]-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Re: Update Table
Yes I know the sql instrution, but where i have to write in my code?
-
Benwahballz
- Forum Commoner
- Posts: 25
- Joined: Mon Sep 21, 2009 12:54 pm
Re: Update Table
mariolopes wrote:Yes I know the sql instrution, but where i have to write in my code?
You need to write it in your code on the page that the data is being submitted to. In this case, it appears that it would be selecciona.php (as noted by aravona)
-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Re: Update Table
Sorry guys
I think i mispresent my problem. Selecciona.php is the unique file I have. Is the file I show.My question is where inside my file, selecciona.php, i have to write the update code.
(before the </html> tag?)
I think i mispresent my problem. Selecciona.php is the unique file I have. Is the file I show.My question is where inside my file, selecciona.php, i have to write the update code.
(before the </html> tag?)
-
Benwahballz
- Forum Commoner
- Posts: 25
- Joined: Mon Sep 21, 2009 12:54 pm
Re: Update Table
If you want the updated data to be included in the table of names (Nome?), you need to perform the update BEFORE the select statment.