I want to be able to have the table take the field post_id = 2, 5, 8, 14 and then update the field named order for each of those rows to say 1, 2, 3, 4 within that loop. The end game is to be able to resort on a per page basis a group of database #id back into 1,2,3,4... depending on which category I load. All of this so I can have a two column category filtered database (odd on left column even on the right). I have been racking my brain for nearly a week and can't believe there is no bi-dimensional repeat region capability in DW6 that could solve this. Thank you in advance
mysql_select_db($database_connTest, $connTest);
$query_RS_Odd = "SELECT projects.post_id, projects.feature_image, projects.`order` FROM projects WHERE projects.landscape = 'landscape'";
$RS_Odd = mysql_query($query_RS_Odd, $connTest) or die(mysql_error());
$row_RS_Odd = mysql_fetch_assoc($RS_Odd);
$totalRows_RS_Odd = mysql_num_rows($RS_Odd);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="styles/Cowen_Website.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table>
<?php do { ?>
<img src="<?php echo $row_RS_Odd['feature_image']; ?>" style="width:30%; margin-bottom:10%; margin-left:auto; margin-right:auto; display:block;"/>
<p style="text-align:center"><?php
if ($row_RS_Odd['post_id'] == 1){
$row_RS_Odd['order']=1;
$resort_next = 1;
echo $row_RS_Odd['post_id'];
mysql_query("UPDATE project SET order=$resort_next WHERE post_id=%s");
}
else if ($row_RS_Odd['post_id'] != 1 && $next==NULL)
{
$resort_next = 1;
$next = $resort_next + 1;
$row_RS_Odd['order']=$resort_next;
echo $resort_next;
echo $row_RS_Odd['post_id'];
mysql_query("UPDATE project SET order=$resort_next WHERE post_id=%s");
}
else if ($row_RS_Odd['post_id'] != 1 && $next!=NULL)
{
$resort_next = $next;
$next = $resort_next + 1;
$row_RS_Odd['order']=$resort_next;
echo $resort_next;
echo $row_RS_Odd['post_id'];
mysql_query("UPDATE project SET order=$resort_next WHERE post_id=%s");
}
else {
echo 'No records found';
}
mysql_query("UPDATE projects SET order=3 WHERE post_id=3");
?>
<?php } while ($row_RS_Odd = mysql_fetch_assoc($RS_Odd)); ?></p>
<?php
$next=0;
?>
</table>
</body>
</html>
<?php
mysql_free_result($RS_Odd);
?>
I should add that I am able to get it to report the variable $resort_next with each row perfectly so that it does indeed echo the correct accompanying resort_next# with the post_id# as you can see in the code. The problem is then after it echos that, I cant seem to get my database to update with that variable (no syntax errors or anything, just wont update)

New Topic/Question
Reply



MultiQuote





|