Xtremer360 Posted February 25, 2009 Share Posted February 25, 2009 Okay what I want is for the two fields is for it to find out how many rows there are in the DB. I want it to display this: <form method=post><input type=hidden name=action value=title><input type=hidden name=down value=yes><input type=hidden name=title value=><input type=hidden name=sortorder value=1><input type=submit value=↓ class=button15></form> for first row and then this: <form method=post><input type=hidden name=action value=title><input type=hidden name=up value=yes><input type=hidden name=titleid value=16><input type=hidden name=sortorder value=6><input type=submit value=↑ class=button15></form> for the last row and ten this for every row in between: <form method=post><input type=hidden name=action value=title><input type=hidden name=up value=yes><input type=hidden name=titleid value=18><input type=hidden name=sortorder value=5><input type=submit value=↑ class=button15></form> <form method=post><input type=hidden name=action value=title><input type=hidden name=down value=yes><input type=hidden name=titleid value=18><input type=hidden name=sortorder value=5><input type=submit value=↓ class=button15></form> With how I have my coding setup I'm not sure how to put that into it. function titles() { print '<h1 class="backstage">Title Management</h1><br />'; print "<h2 class=\"backstage\">Titles :: <a href=\"#\" onclick=\"ajaxpage('addtitle', 'content'); return false;\">Add New</a></h2><br />"; $query = "SELECT * FROM titles ORDER BY `name`"; $result = mysql_query ( $query ); // Run The Query $rows = mysql_num_rows($result); if ($rows > 0) { print '<table width="100%" class="table1">'; print '<tr class="rowheading">'; print '<td> </td>'; print '<td width="40" align="center">Order</td>'; print '<td> </td>'; print '<td> </td>'; print '<td width="100" align="center">Shortname</td>'; print '<td>Name</td>'; print '<td align="center" width="50">Style</td>'; print '<td align="center" width="40">Active</td>'; print '</tr>'; // Fetch and print all records. $i = 0; while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) { $sClass = 'row2'; if ($i ++ & 1) { $sClass = 'row1'; } printf ( "<tr class=\"%s\">", $sClass ); print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"edittitle('edittitle', 'content' , '". $row ['name'] ."'); return false;\">Edit</a></td>"; printf ( "<td align=\"center\" valign=\"top\" width=\"40\">%s</td>", $row [order] ); print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"edittitle('edittitle', 'content' , '". $row ['name'] ."'); return false;\">Edit</a></td>"; print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"edittitle('edittitle', 'content' , '". $row ['name'] ."'); return false;\">Edit</a></td>"; print "<td align=\"center\" valign=\"top\" width=\"100\"><a href=\"content.php?p=champions&s=". $row ['shortname'] ."\" return false;\">" . $row ['shortname'] . "</a></td>"; printf ( "<td valign=\"top\">%s</td>", $row [name] ); printf ( "<td valign=\"top\" width=\"50\" align=\"center\" >%s</td>", $row [style] ); printf ( "<td align=\"center\" valign=\"top\" width=\"40\">%s</td>", $row [active] ); print '</tr>'; } echo '</table>'; } else { print '<span>There are no titles.</span><br />'; } print '<br />'; print '<h2 class="backstage"><input type="button" value="Return to Main Menu" class="button200"></form></h2>'; } Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted February 25, 2009 Author Share Posted February 25, 2009 Here's my updated code and it does work correctly so far now I'm too the point where I have to tell in my code somehow what the buttons are actually supposed to do and everything. What they are supposed to do is obviously depending on the button either change the order number up or down. function titles() { print '<h1 class="backstage">Title Management</h1><br />'; print "<h2 class=\"backstage\">Titles :: <a href=\"#\" onclick=\"ajaxpage('addtitle', 'content'); return false;\">Add New</a></h2><br />"; $query = "SELECT * FROM titles ORDER BY `order`"; $result = mysql_query ( $query ); // Run The Query $rows = mysql_num_rows($result); if ($rows > 0) { print '<table width="100%" class="table1">'; print '<tr class="rowheading">'; print '<td> </td>'; print '<td width="40" align="center">Order</td>'; print '<td width="1"> </td>'; print '<td width="1"> </td>'; print '<td width="100" align="center">Shortname</td>'; print '<td>Name</td>'; print '<td align="center" width="60">Style</td>'; print '<td align="center" width="40">Active</td>'; print '</tr>'; // Fetch and print all records. $i = 0; $current_row = 0; while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) { $current_row++; $sClass = 'row2'; if ($i ++ & 1) { $sClass = 'row1'; } printf ( "<tr class=\"%s\">", $sClass ); print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"edittitle('edittitle', 'content' , '". $row ['name'] ."'); return false;\">Edit</a></td>"; printf ( "<td align=\"center\" valign=\"top\" width=\"40\">%s</td>", $row [order] ); print "<td valign=\"top\" align=\"center\" width=\"1\">"; if($current_row == 1){ echo ""; } else if($current_row == $rows){ echo "<form method=post><input type=hidden name=action value=title><input type=hidden name=up value=yes><input type=hidden name=titleid value=16><input type=hidden name=sortorder value=6><input type=submit value=↑ class=button15></form>"; } else { echo "<form method=post><input type=hidden name=action value=title><input type=hidden name=up value=yes><input type=hidden name=titleid value=18><input type=hidden name=sortorder value=5><input type=submit value=↑ class=button15></form>"; } print "</td><td valign=\"top\" align=\"center\" width=\"1\">"; if($current_row == 1){ echo "<form method=post><input type=hidden name=action value=title><input type=hidden name=down value=yes><input type=hidden name=title value=><input type=hidden name=sortorder value=1><input type=submit value=↓ class=button15></form>"; } else if($current_row == $rows){ echo ""; } else { echo "<form method=post><input type=hidden name=action value=title><input type=hidden name=down value=yes><input type=hidden name=titleid value=18><input type=hidden name=sortorder value=5><input type=submit value=↓ class=button15></form>"; } print "</td><td align=\"center\" valign=\"top\" width=\"100\"><a href=\"content.php?p=champions&s=". $row ['shortname'] ."\" return false;\">" . $row ['shortname'] . "</a></td>"; printf ( "<td valign=\"top\">%s</td>", $row [name] ); printf ( "<td valign=\"top\" width=\"60\" align=\"center\" >%s</td>", $row [style] ); printf ( "<td align=\"center\" valign=\"top\" width=\"40\">%s</td>", $row [active] ); print '</tr>'; } echo '</table>'; } else { print '<span>There are no titles.</span><br />'; } print '<br />'; print '<h2 class="backstage"><input type="button" value="Return to Main Menu" class="button200"></form></h2>'; } Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted February 26, 2009 Author Share Posted February 26, 2009 *bump* 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.