I inserted a single link to database with a single field ‘addlink’, likewise i inserted again & again and now totally i have
5 rows. How can i get all the rows from database and update them. Please help with this.
/*——————-Inserting working Successfully */
echo ‘<font size=”4px” face=”verdana”><b>Add a New Link</b></font><br><br>’;
if($_SERVER['REQUEST_METHOD']==’POST’)
{
$add1 = $_REQUEST["add"];
$sql=”INSERT INTO mdl_block_left_menu_front(addlink) values(‘$add1′)”;
$a=mysql_query($sql);
if(!$a)
{
error(‘There was an error while inserting the link’);
}
else
{
echo “Changes saved Successfully”;
}
}
echo ‘<form name=”fname” action=”add.php” method=”post”>’;
echo ‘Add a link : <input type=”field” name=”add”><br><br>’;
echo ‘<input type=”submit” value=”submit”></form>’;
/*————————— Need help in updating
echo ‘<td id=”middle-column” style=”text-align:center;”>’;
echo ‘<font size=”4px” face=”verdana”><b>Edit Link</b></font><br><br>’;
$list = get_records_sql(‘SELECT * FROM mdl_block_left_menu_front’);
/* Displaying the field values from database */
foreach($list as $listed)
{
$addlinky = $listed->addlink;
echo ‘<form name=”f” action=”update.php” method=”post”>’;
echo ‘<table width=150 cellspacing=4 cellpadding=4><tr align=center><td><input type=”text” value=”‘.$addlinky.’”</td></tr></table>’;
}
/* Displaying the field values from database */
echo ‘<input type=”submit” value=”submit”></form>’;
/* Editing the field values and submitting again to the database */
if($_SERVER['REQUEST_METHOD']==’POST’)
{
$sql=’UPDATE mdl_block_left_menu_front SET addlink=”‘.$addlinky.’”‘;
//echo ‘UPDATE mdl_block_left_menu_front SET addlink=’.$addlinkyy.”;
$a=mysql_query($sql);
if(!$a)
{
error(‘There was an error while inserting the link’);
}
else
{
echo “Changes saved Successfully”;
}
}
/* Editing the field values and submitting again to the database */
echo ‘</td>’;

January 23rd, 2011
gansai
Posted in
Tags: 











































