Need help for updating multiple looping rows of SQL by php
Posted: Sat Dec 31, 2011 5:45 am
Hi there,
I am getting stack of updating multiple looping rows of SQL by php. Can anyone help me, please? My code is showing result but it doesn't upload any query. Here I am writing my code
I guess there has problem of line as i am getting message
Kind Regards,
Bahalul
I am getting stack of updating multiple looping rows of SQL by php. Can anyone help me, please? My code is showing result but it doesn't upload any query. Here I am writing my code
Code: Select all
<?php include('include/db_connect.php'); ?>
<?php if(isset($_POST['Level'])){$Level = $_POST['Level'];
$id = "('" . implode( "','", $Level ) . "');" ;
$sql="UPDATE Webaccounts1 SET Level = $Level WHERE ID IN $id" ;
$result = mysql_query($sql) or die(mysql_error());
}
$sql="SELECT * FROM Webaccounts1";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<form id="form1" name="form1" method="post" action="">
<table width="600" border="2">
<tr> <td colspan="4" ><input name="Update" type="submit" value="update" /> </td> </tr>
<tr> <td width="98">Login Name</td><td width="177" >Rank </td> <td width="60">Class</td> <td width="170">Main Character Profile</td> </tr>
<?php
$result = mysql_query("SELECT * FROM Webaccounts1 Order By Charname");
//declaring value:
$counter="0";
//Looping:
while($row = mysql_fetch_array($result))
{
//Applying condition
echo "<tr><td>".$row['Charname']."</td>"; $level=$row['level']; { ?>
<td> <select name="Level[]">
<option value="<?php echo $row['Level'] ?>" selected="selected"><?php echo $row['Level']?></option>
<option value="Guest" >Guest</option>
<option value="Hall of Shame">Hall of Shame</option>
<option value="Initiate">Initiate</option>
<option value="Member">Member</option>
<option value="Veteran">Veteran</option>
<option value="Cadet">Cadet</option>
<option value="Event Manager">Event Manager</option>
<option value="Raid Leader">Raid Leader</option>
<option value="Battle Master and Bank Master">Battle Master and Bank Master</option>
<option value="Officer">Officer</option>
<option value="Legendary">Legendary</option>
<option value="Guild Master">Guild Master</option></select></td>
<td><?php echo $row['Class'] ?></td>
<td><a href="http://armory.neverendless-wow.com/characters/<?php echo $row['ingame_ch'] ?>" target="_new"><?php echo $row['ingame_ch'] ?> </a></td>
</tr><?php }
$counter++;
}
echo "</table>";
echo "counter = <input type=\"text\" name=\"total_items\" size=\"4\" value=\"" . $counter . "\">";
mysql_close($conect);?>
<tr> <td colspan="4" ><input name="Update" type="submit" value="update" /> </td> </tr>
</form>
Code: Select all
$sql="UPDATE Webaccounts1 SET Level = $Level WHERE ID IN $id" ;Please, Help me.Unknown column 'Array' in 'field list'
Kind Regards,
Bahalul