penguin0 Posted June 3, 2007 Share Posted June 3, 2007 I already know how to do this, but I am getting incorrect results. $mnum = intval($_REQUEST['number']); if ($mnum > 0) { $pmove = intval($_REQUEST['pmove']); $smove = intval($_REQUEST['smove']); $mpos = intval($_REQUEST['position']); if ($pmove = "1") { $sql = "UPDATE menu SET position = $mpos + $pmove WHERE number = $mnum"; $result = @mysql_query($sql, $link) or die(mysql_error()); } if ($smove = "1") { $sql = "UPDATE menu SET position = $mpos - $smove WHERE number = $mnum"; $result = @mysql_query($sql, $link) or die(mysql_error()); } } $result = mysql_query( "SELECT number, name, link, position, isparent, private, modified FROM menu WHERE private = 1 ORDER BY position" ); $num_rows = mysql_num_rows( $result ); while ( $row = mysql_fetch_array( $result ) ) { $mnumber = $row['number']; $mname = $row['name']; $mlink = $row['link']; $mposition = $row['position']; $misparent = $row['isparent']; $mprivate = $row['private']; $modified = $row['modified']; if ($misparent == "0") { $starttag = "<td class=ac><a href=\"editmenu.php?number=$mnumber\"><img src=\"/romac/images/info.gif\" border=\"0\"></a></td><td class=ac>$mposition</td><td><a href=\"?position=$mposition&smove=1&pmove=0&number=$mnumber\">Move Up</a><br /><a href=\"?position=$mposition&pmove=1&smove=0&number=$mnumber\">Move Down</a></td><td class=\"off\" onmouseover=\"this.className=\" onmouseout=\"this.className=\" height=\"30\" align=\"left\" valign=\"middle\"><a href=\"$mlink\" class=\"left_menu_text\">"; $endtag = "</a></td><td>$modified</td><td class=ac><a href=\"delmenu.php?number=$mnumber\"><img src=\"/romac/images/del.png\" border=\"0\"></td></tr>"; } else { $starttag = "<td class=ac><a href=\"editmenu.php?number=$mnumber\"><img src=\"/romac/images/info.gif\" border=\"0\"></a></td><td class=ac>$mposition</td><td><a href=\"?position=$mposition&smove=1&pmove=0&number=$mnumber\">Move Up</a><br /><a href=\"?position=$mposition&pmove=1&smove=0&number=$mnumber\">Move Down</a></td><TH><br>"; $endtag = "<br><br></TH></td><td>$modified</td><td class=ac><a href=\"delmenu.php?number=$mnumber\"><img src=\"/romac/images/del.png\" border=\"0\"></td></tr>"; } $menu_block2 .= " <tr>$starttag$mname</a>$endtag"; } $result = mysql_query( "SELECT number, name, link, position, isparent, private, modified FROM menu WHERE private = 0 ORDER BY position" ); $num_rows2 = mysql_num_rows( $result ); while ( $row = mysql_fetch_array( $result ) ) { $mnumber = $row['number']; $mname = $row['name']; $mlink = $row['link']; $mposition = $row['position']; $misparent = $row['isparent']; $mprivate = $row['private']; $modified = $row['modified']; if ($misparent == "0") { $starttag = "<td class=ac><a href=\"editmenu.php?number=$mnumber\"><img src=\"/romac/images/info.gif\" border=\"0\"></a></td><td class=ac>$mposition</td><td><a href=\"?position=$mposition&smove=1&pmove=0&number=$mnumber\">Move Up</a><br /><a href=\"?position=$mposition&pmove=1&smove=0&number=$mnumber\">Move Down</a></td><td class=\"off\" onmouseover=\"this.className=\" onmouseout=\"this.className=\" height=\"30\" align=\"left\" valign=\"middle\"><a href=\"$mlink\" class=\"left_menu_text\">"; $endtag = "</a></td><td>$modified</td><td class=ac><a href=\"delmenu.php?number=$mnumber\"><img src=\"/romac/images/del.png\" border=\"0\"></td></tr>"; } else { $starttag = "<td class=ac><a href=\"editmenu.php?number=$mnumber\"><img src=\"/romac/images/info.gif\" border=\"0\"></a></td><td class=ac>$mposition</td><td><a href=\"?position=$mposition&smove=1&pmove=0&number=$mnumber\">Move Up</a><br /><a href=\"?position=$mposition&pmove=1&smove=0&number=$mnumber\">Move Down</a></td><TH><br>"; $endtag = "<br><br></TH></td><td>$modified</td><td class=ac><a href=\"delmenu.php?number=$mnumber\"><img src=\"/romac/images/del.png\" border=\"0\"></td></tr>"; } $menu_block3 .= " <tr>$starttag$mname</a>$endtag"; } if ($num_rows > "0") { echo "<a class=\"orange_link\" href=\"addmenu.php\">Add Menu</a><br /><br />\n"; echo "<table border=0 cellpadding=1 cellspacing=1 class=\"ptable\" width=\"100%\"><tr><TH colspan=\"6\">Private Menu layout</TH></tr>\n <tr><TH>Edit</TH><TH>Position</TH><TH>Move</TH><TH>Structure</TH><TH>Modified</TH><TH>Del</TH>"; echo "$menu_block2"; echo "<tr><td colspan=\"6\">"; echo "Total Menus: $num_rows"; echo "</td></tr></table>"; } if ($num_rows2 > "0") { echo "<br><table border=0 cellpadding=1 cellspacing=1 class=\"ptable\" width=\"100%\"><tr><TH colspan=\"6\">Public Menu layout</TH></tr>\n <tr><TH>Edit</TH><TH>Position</TH><TH>Move</TH><TH>Structure</TH><TH>Modified</TH><TH>Del</TH>"; echo "$menu_block3"; echo "<tr><td colspan=\"6\">"; echo "Total Menus: $num_rows2"; echo "</td></tr></table></td></tr>"; } I know there is a lot of code, but for some reason, when I click the link <a href=\"?position=$mposition&pmove=1&smove=0&number=$mnumber\">Move Down</a> It changes pmove to 1 and smove to 1. I have no idea why this is happening, otherwise I would not post all this. Also it will always -1, even if I click move down. Quote Link to comment Share on other sites More sharing options...
dough boy Posted June 3, 2007 Share Posted June 3, 2007 I am not sure if this has anything to do with it, but when you are evaluating a condition you must use 2 equal signs (==) vs (=). if ($pmove = "1") if ($smove = "1") Basically what you are doing is setting these values to 1 (which then equates to true so they will always be executed). You also should use single quotes instead of double quotes as PHP then has to parse what is inside the double quote to see if there is a variable in there. Quote Link to comment Share on other sites More sharing options...
penguin0 Posted June 3, 2007 Author Share Posted June 3, 2007 Yeah that wast it.... Quote Link to comment Share on other sites More sharing options...
dough boy Posted June 3, 2007 Share Posted June 3, 2007 K. I hate it when I do things like that. It is always something simple and you stare at it for hours and then you ask 1 person and they find it in 2 seconds. Drives me nuts! If I was smart I would use Zend Studio but I am used to what I am used to. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.