I am trying to update the sequence of several records at the same time so when I have them outputted they output in the sequence order.. For some reason, I am having a hard time passing the sequence information to the sql script.... I have no clue what I am doing wrong here..
?
include ("./header.php");
error_reporting(5);
if ($SAVE == "Submit") {
$seq = $HTTP_POST_VARS["sequence_".$id];
echo "seq=" , $seq;
echo "<P>";
$sequ[$number] = $seq;
//$x = count($sequence);
//for ($i =0; $i < count($sequence); $i++) {
//echo "sequence", $sequence[$i];
for ($m =0; $m < count($id); $m++) {
echo $id[$m];
$sql = "update portfolio set sequence='$sequ[$number]' where cateogry='$category' and id='$id[$m]'";
$res = pg_Exec($db, $sql);
echo "$sql<p>";
//}
//}
}
}
?>
<center>
<a href="port_ouput.php">OUTPUT</a> | <a href="portfolio_uploader.php">UPLOAD</a> | <a href=port_view_del.php>VIEW/DELETE</a>
<p>
<form action="<? echo $PHP_SELF ?>" method="POST">
<input type=hidden name=category value=<? echo $category ?>>
<table><th>ID</th><th>Title</th><th>Category</th><TH>Filename</TH><TH>Description</TH><TH>Featured</TH><tH>Sequence</th>
<?
$sql = "select * from portfolio where cateogry='$category' order by sequence";
$res = pg_Exec($db, $sql);
$num = pg_NumRows($res);
for ($cnt = 0; $cnt < $num; $cnt++) {
$id = pg_result ($res,$cnt, 0);
$title= pg_result ($res,$cnt, 2);
$category= pg_result ($res,$cnt, 3);
$desc = pg_result ($res,$cnt, 4);
$filename = pg_result ($res,$cnt, 5);
$url = pg_result ($res,$cnt, 6);
$sequence = pg_result ($res,$cnt, 7);
$featured = pg_result ($res,$cnt, 8);
echo "<tr><td><input type=hidden name=id[] value=$id>" , $id ,"</td><td>" , $title ,"</td><td>";
$sql2 = "select cname from category where id = $category ";
$res2 = pg_exec($db, $sql2);
$total = pg_NumRows($res2);
for($i = 0; $i < $total; $i++) {
$cat = pg_result($res2, $i, 0 );
echo $cat;
}
echo "</td><td>" , $filename , "</td><td>", $desc ,"</td><td>";
$sql3 = "select id,fname from featured where id = '$featured'";
$res3 = pg_exec($db, $sql3);
$total3 = pg_NumRows($res3);
for($n = 0; $n < $total3; $n++) {
$ids = pg_result($res3, $n, 0 );
$feat = pg_result($res3, $n, 1 );
echo "$feat";
}
//for ($l=1; $l <= $num; $l++) {
echo "<td><select name=sequence_$id>";
for ($j=1; $j <= $num; $j++) {
echo "<option value=", $j-1, ">" , $j-1;
}
}
echo "</select></td></tr>";
//}
?>
</table>
<center>
<input type="submit" name="SAVE" value="Submit"><input type="reset"></center><p></p>
<? include ("./footer.php");
?>