| | |
unable to update my table
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
hi
when edit link is clicked the form with the filled in fields will get displayed .the user the can edit the content in the fields and then when he clicks update the table will get updaed
here is my code...
here id is auto generating field in mysql
1st page
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$line = $_GET['id'];
$result=mysql_query("SELECT * FROM table1 where id='$line'") or die("ERROR:".mysql_error());
for ($i = 0; $i < mysql_num_rows($result); ++$i)
{
$line = mysql_fetch_row($result);
print 'Name<input type="text" maxlength="19" size="53" name="name1" value="'.$line[0].'" />';
print '<input type="hidden" maxlength="19" size="53" name="name1" value="'.$line[0].'" />';
print '<input type="Submit" name="Submit" value="Submit" />';
}
2nd page
$name1=$_POST['name1'];
$id1=$_POST['id'];
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
if (isset($_REQUEST['Submit']))
{
mysql_query("UPDATE table1 SET name='$name1' where id='$id1'") or die("ERROR:".mysql_error());
echo $name1;
echo $id1;
echo "THANKS FOR ENTERING UR DETAILS";
}
but the date is not getting updated
when edit link is clicked the form with the filled in fields will get displayed .the user the can edit the content in the fields and then when he clicks update the table will get updaed
here is my code...
here id is auto generating field in mysql
1st page
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
$line = $_GET['id'];
$result=mysql_query("SELECT * FROM table1 where id='$line'") or die("ERROR:".mysql_error());
for ($i = 0; $i < mysql_num_rows($result); ++$i)
{
$line = mysql_fetch_row($result);
print 'Name<input type="text" maxlength="19" size="53" name="name1" value="'.$line[0].'" />';
print '<input type="hidden" maxlength="19" size="53" name="name1" value="'.$line[0].'" />';
print '<input type="Submit" name="Submit" value="Submit" />';
}
2nd page
$name1=$_POST['name1'];
$id1=$_POST['id'];
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");
if (isset($_REQUEST['Submit']))
{
mysql_query("UPDATE table1 SET name='$name1' where id='$id1'") or die("ERROR:".mysql_error());
echo $name1;
echo $id1;
echo "THANKS FOR ENTERING UR DETAILS";
}
but the date is not getting updated
php Syntax (Toggle Plain Text)
print '<input type="hidden" maxlength="19" size="53" name="name1" value="'.$line[0].'" />';
php Syntax (Toggle Plain Text)
print '<input type="hidden" maxlength="19" size="53" name="id1" value="'.$line[0].'" />';
in page 1, because, in page2, ur trying to access $_POST[$id1] which never existed !
Last edited by nav33n; Nov 29th, 2007 at 8:22 am. Reason: Added more.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
Oh, btw, you cant pass the data from 1page to another without using <form>. Try the following.
I hope it helps.
php Syntax (Toggle Plain Text)
<?php //page1.php $link=mysql_connect($hostname, $username, $password); mysql_select_db($dbid) or die("unable to connect"); $line = $_GET['id']; $result=mysql_query("SELECT * FROM table1 where id='$line'") or die("ERROR:".mysql_error()); for ($i = 0; $i < mysql_num_rows($result); ++$i) { $line = mysql_fetch_row($result); print '<form name="test" method="post" action="page2.php">'; print 'Name<input type="text" maxlength="19" size="53" name="name1" value="'.$line[0].'" />'; print '<input type="hidden" maxlength="19" size="53" name="id" value="'.$line[0].'" />'; print '<input type="Submit" name="Submit" value="Submit" />'; print '</form>'; } ?> <?php //page2.php $name1=$_POST['name1']; $id1=$_POST['id']; $link=mysql_connect($hostname, $username, $password); mysql_select_db($dbid) or die("unable to connect"); if (isset($_REQUEST['Submit'])) { mysql_query("UPDATE table1 SET name='$name1' where id='$id1'") or die("ERROR:".mysql_error()); echo $name1; echo $id1; echo "THANKS FOR ENTERING UR DETAILS"; } ?>
I hope it helps.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- no bandwidth while connected and unable to disconnect after an error occur. (Viruses, Spyware and other Nasties)
- update sql (PHP)
- I cannot access certain websites or update AVG, AdAware etc (Viruses, Spyware and other Nasties)
- Unable to remove Virus Alert, Pop Ups & IE Start Up page .. help ... (Viruses, Spyware and other Nasties)
- Unable to view yahoo mail or online bank account etc (Viruses, Spyware and other Nasties)
- I am unable to login, usernames are gone (Viruses, Spyware and other Nasties)
- This ought to be simple - extra spaces (PHP)
Other Threads in the PHP Forum
- Previous Thread: oracle insert query failing + php
- Next Thread: .dco file from blob
| Thread Tools | Search this Thread |
# 5.2.10 action address apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display dissertation domain dynamic echo echo$_get[x]changingitintovariable... email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image images include insert ip javascript joomla legislation limit link load login mail masterthesis menu mlm multiple mysql mysqlquery oop open paypal pdf persist php popup problem query radio random record recursion remote script search server sessions sms sockets source space sql syntax system table tutorial update upload url validator variable video web youtube






