PHP: Create a HTML drop down/select box from a database

January 28, 2010 – 11:22 am

Here is a function I use all of the time. It takes the contents of a mySQL table and creates an HTML select box (I call them drop downs) from it.



# $table: The mySQL table to use.
# $column: The column in $table to display
# $name: The HTML name of the drop down
# $selected: The value that the drop down defaults to.
# $show_any: If you have a row in the table where the $column equals
                    00_Any it will be displayed.
#                  This is useful for having an Any or All value.
# $distinct: Only show DISTINCT() $column
function dropdown_db($table, $column, $name, $selected,
                              $show_any = 1, $distinct = 0) {

  $dropdown = "<select id=\"$name\" name=\"$name\">\n";

  $any_sql = '';
  if(!$show_any) {
    $any_sql = " WHERE $column <> '00_Any' ";
  }

  $select = $column;
  if($distinct) {
    $select = "DISTINCT($column)";
  }

  $from_db = "SELECT $select FROM $table $any_sql ORDER by $column";
  $from_db2 = mysql_query($from_db) ;
  while($from_db3=mysql_fetch_array($from_db2, MYSQL_ASSOC)) {

    $value = $from_db3["$column"];

    $pretty_db = $value;
    $pretty_db = str_replace('00_', '', $pretty_db);
    $pretty_db = str_replace('_', ' ', $pretty_db);

    $SELECTED = '';
    if($value == $selected) {
        $SELECTED = ' SELECTED';
    }

    $dropdown .= "<option value=\"$value\"$SELECTED>$pretty_db</option>\n";
  }

  $dropdown .= "</select>\n";

  return($dropdown);
}

How to Cheat at Cafe World

December 31, 2009 – 2:40 pm

Cafe World is a time management game that is all the rage on Facebook. I use the term loosely because it is not much of a game in my opinion. You click some things for a minute or two then wait a day. You do this over and over again and it is supposed to be fun.

The game's logic appears to be almost entirely in the client and the server will accept any old data. For fun and profit I used Cheat Engine to speed time up in the game so my dishes cooked 20x faster than normal.

Here is how I did it.

  1. Load up Cafe World
  2. Start Cheat Engine
  3. Click Search
  4. Find Firefox and click it.
  5. Click open.
  6. Check Enable Speed Hack
  7. Set the Speed to 20. Any lower is too slow, any higher and it won't work.
  8. Click Apply.
  9. Make the longest taking highest level dishes you can.
  10. Repeat 9 until you get tired.
  11. Make your fiance cry because you just surpassed her months of work in a week.
cheat_engine

A note about the speed setting. It may seem like a good idea to crank that sucker up to 500, but you quickly lose connection with the server and the game reloads. Once the game reloads the time left on your dishes resets to what they should be.

Another note... this method should work on any of the time based games on FB. Good times.

OpenSwan to Cisco 7XXX Config

November 13, 2009 – 11:37 am

Oh hey, there! What's up? This was a week long project that should have been twenty minutes at most.

I hate VPNs.  Call me odd, but I think the protocols should have the encryption built in.  If you need it use it, if not, don't.

net-to-net.conf:

conn net-to-net
        type=           tunnel
        authby=         secret
        left=           MY PUBLIC IP
        leftnexthop=    MY DEFAULT GATEWAY
        leftsubnet=     MY PUBLIC IP/32
        right=          REMOTE PUBLIC IP
        rightsubnet=    REMOTE PRIVATE IP/32
        keyexchange=    ike
        pfs=            no
        auto=           start
        ike=3des-md5-modp1024,3des-md5-modp1536
        esp=3des-md5

net-to-net.secrets:

MY PUBLIC IP REMOTE PUBLIC IP: PSK "password"

Labor Day!

September 7, 2009 – 5:48 pm 100_1071

3 Fast, 3 Furious – Tokyo Drift

August 25, 2009 – 10:47 am 5729_102402779773460_100000112168596_48405_4366388_n.jpg

My Garage is Complete!

July 28, 2009 – 5:49 pm

At least close enough that I'm calling it!



thevedic.net

Part of the thevedic.net.
[Contact Me] - [Mud Emporium] - [Ozark, AR] - [See my Port?]

This site is in no way represents the opinions or positions of any company or organization including those who employ the creators of this web site. We're not responsible for the content, posts, responses by other users or ideas of any sites that are linked to on this page. This site is recommended for ages 18 and up.

VEDIC VEKO IS PROSPEROUS

Arkie Imports | Dean Vaughan | Dean Vaughan | K. Dean Vaughan | Kenneth Vaughan | Pig Trail 23 | Pig Trail Pics | See My Port Forward Info | See My Port Forward Info


I'm not affiliated with the following in anyway.
Arkansas MMA - Inferno Mixed Martial Arts - Inferno Martial Arts Club - Inferno Martial Arts Club - Official Inferno Fight Gear - Inferno Fight Equipment - Inferno Combat Gear - IFC Online - Inferno Fight Gear - Inferno MMA - Inferno Fight Gear