Jump to content

Classes Plus Number of Rows


Xtremer360

Recommended Posts

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>';
}  

Link to comment
Share on other sites

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>';
} 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.