hej mam dwa skrypty pierwszy
edit.php
do wprowadzania zmian do rekordu
dziala dobrze dla wszystkich pol poza chceckbox oraz ID - ID chce updatowac aby moc przesowac rekordy w kolejnosci - chyba ze ktos zna leprzy sposob chetnie sie naucze czegos nowego (IMG:
http://forum.php.pl/style_emoticons/default/smile.gif)
co do checkbox ustawilem go tak zeby zapisywal sie w bazie gdy jest zaznaczony jako '1' gdy jest nie zaznaczony wprowadza '0'
drugi
update.php
edit.php<?php
include('header.php');
include('../top.php');
$id=$_GET['id'];
include("../../../config.inc.php");
$query="SELECT * FROM portfolio WHERE id='$id'";
$i=0;
while ($i < $num) {
if($string=='1')
{
$string='CHECKED';
}
else{
$string='';
}
?>
<div align="center">
<form method="post" action="update.php">
<table width="95%" border="1" id="tabelka-frame">
<tr>
<td width="22%" valign="top"><a href="../../control.php?location=listportfolio" class="link">List all entrees</a></td>
<td><div id="panelcont" align="right">URL:</div></td>
<td><div id="panelcont" align="left"><input name="port_url" type="text" value="
<? echo "$port_url"; ?>" size="45" maxlength="50" class="box" />
ID: <input name="up_id" type="text" value="
<? echo "$id"; ?>" size="5" maxlength="50" class="box" /></div></td>
</tr>
<tr>
<td valign="top"><img src="../../../graphic/portfolio/
<? echo "$name"; ?>" /></td>
<td width="6%" valign="top"><div id="panelcont">short description:</div></td>
<td><textarea name="description" cols="45" rows="12" class="box" >
<? echo "$description"; ?></textarea></td>
</tr>
<tr>
<td valign="top"><br /></td>
<td colspan="2"><br /><br />
<div id="panelcont">
<input type="checkbox" name="tablica[0]" value="1"
<? echo "$string"; ?> />
- Mark it to make this portfolio visable on website</div></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><input name="upload" type="submit" class="box" id="upload" value=" Submit " /></td>
</tr>
</table>
</form>
</div>
<?php
$i++;
}
include('bottom.php');
include('../../footer.php');
?>
update.php<?php
$up_id = $_POST['up_id'];
$description = $_POST['description'];
$port_url = $_POST['port_url'];
include ("../../../config.inc.php");
$array = $_POST['tablica'];
$string = NULL;
for( $i = 0;
$i <= 0; $i++ )
{
if( ! isset ( $array[ $i ] ) ) $string .= 0;
else
$string .= $array[ $i ];
}
$query = "UPDATE portfolio SET id='$up_id',description='$description',port_url='$port_url',string='$string' WHERE id='$id'";
echo "Data updated succesfuly !"; ?>
Ten post edytował andy84 20.05.2007, 10:13:21