Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2009
    UK: Oxford

    Unhappy Check for unique in PHP from MySQL?

    Good evening,

    I am in need of some help, I have been working on a website for a logistics company. I have been designing the site so the admin panel has complete controll over pages, menus ect..

    I have given the admin permission to adjust the order of the menu items, but this is done with a simple equation of if [ITEM] value = 1 - You can only go up and if at [MAX] value item, you can only go down and anything in between can go either way.

    However, this does cause an error where things can have the same order value, so I want to highlight with a background color (light red) to let them know they have to change it.

    This is a mysql_fetch_array and uses a table row to display each result.

    Is there a way of doing this? I have been looking at loops, and Unique arrays but I cant get it to work.

    echo "<td valign=\"middle\" align=\"center\" ";
    //<-- Start Background color here!
    						echo "bgcolor=\"#F3787B\"";
    //<-- End Background color here!							
    					echo ">";
    					if($getMenu['order'] == "1") {
    						$up = $getMenu['order'] + 1;
    						echo "<a href=\"".$getMenu['id']."&order=".$up."\"><img src=\"../images/arrow_down.png\" /></a> ".$getMenu['order'];
    					} elseif($getMenu['order'] == $countMenu) {
    						$down = $getMenu['order'] - 1;
    						echo "<a href=\"".$getMenu['id']."&order=".$down."\"><img src=\"../images/arrow_up.png\" /></a>".$getMenu['order'];
    					} else {
    						$up = $getMenu['order'] + 1;
    						$down = $getMenu['order'] - 1;
    						echo "<a href=\"".$getMenu['id']."&order=".$up."\"><img src=\"../images/arrow_down.png\" /></a> ".$getMenu['order'];
    						echo "<a href=\"".$getMenu['id']."&order=".$down."\"><img src=\"../images/arrow_up.png\" /></a>";
    				echo "</td>";
    Above is the controlling code, but I want it so if [HOME] order value = 1 and [CONTACT US] order value = 1 as well, they both highlight with a color.

    Please help as I want to get on with working on the site but this has been holding me up for about an hour and getting me frustrated!
    Garbott Ltd - Professional web development & consultancy services
    Oxford.Hosting - Prestigious shared, cloud, dedicated and gaming hosting solutions.

  2. #2
    Join Date
    Apr 2003
    Los Angeles, CA
    Something like this:

    PHP Code:
    foreach($menuItems as $getMenu)

    $menuItems as $getMenu) {
    $idCounts[$getMenu['order']] > 1)
    // mark it in red

    Pings <1 ms, Unlimited Transfer, Lowest Price: http://localhost/

Similar Threads

  1. Replies: 3
    Last Post: 04-15-2011, 04:47 AM
  2. unique and the index key in php mysql
    By tea_clipper in forum Programming Discussion
    Replies: 3
    Last Post: 01-26-2009, 12:06 PM
  3. $20/year - PHP, MySQL, cPanel & MORE! - - - CHECK IT - - -
    By dbihosting in forum Shared Hosting Offers
    Replies: 0
    Last Post: 12-07-2007, 01:03 PM
  4. PHP - MYSQL Dealing with check boxes
    By saghir69 in forum Programming Discussion
    Replies: 4
    Last Post: 11-25-2004, 06:40 PM
  5. Need Work? Bored? Good with php and mysql? Check this out
    By Genocide in forum Employment / Job Offers
    Replies: 13
    Last Post: 07-01-2003, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts