1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Rep Power

    [Hiring]: $100 for an hour of your time - MySQLi Code

    This will be a rather lengthy post, as I want to ensure I put all the information that may be needed for what I want. I say 'an hour of time' because I could write this in under an hour using Old School MySQL coding, which apparently is depreciated and no longer works. I have neither the time nor the patience to learn MySQLi so I am posting here.

    I am assuming control of a website and trying to update it. Currently, it's a full HTML site and all pages need to be produced statically. The website is designed to list incarcerated females to acquire 'pen pals'. While the old site charged a fee for this service, I am paying all the expensives myself out of pocket.
    I require a grand total of 3 MySQLi queries written in PHP5 code. 2 are simple, one is a bit more complex, but nothing rocket science. I will list the queries 1 at a time...

    1: I need a query to pull a list of prison names from a selected state. This query is generated by a drop down menu using $_POST.
    Example: SELECT prison_name FROM table_name WHERE state = $_POST['state']
    The resulting rows will then populate a 2nd drop down menu which becomes part of a search query.
    Apparantly neither $num = mysql_num_rows($result); nor while($row=mysql_fetch_assoc($result)) work properly anymore.
    2: I need a 'search type' query that has 4 fields - prison_name , age , hair_colour , eye_colour, only the 1st field (prison_name) will be NOT NULL, the other 3 fields could be NULL. The field 'age' will require some sort of $calc(age) since the table field is by DOB in the yyyy-mm-dd format and will have a range of a number of years. Again, these variables will be acquired from 4 drop down menus all using $_POST.
    $select = "SELECT * from table_name ";
    $where = "WHERE state = $_POST['state'] ";
      if (strlen($_POST['ad_dob'])) {
        $where .= "AND ad_dob > '".$calc(minimum_age, ad_dob)."' ";
        $where .= "AND ad_dob <= '".$calc(maximum_age, ad_dob)."' ";
      if (strlen($_POST['ad_hair'])) {
         $where .= "AND ad_hair = '".$_POST['ad_hair'])) ."' ";
      if (strlen($_POST['ad_eyes'])) {
         $where .= "AND ad_eyes = '".$_POST['ad_eyes'])) ."' ";
    $groupby = " group by prison_name";
    $orderby = " order by prison_name";
    $sql = $select.$where.$groupby.$orderby;
    $result = mysql_query($sql);
    $num = mysql_num_rows($result);
    3: I need an insert query to add new listings into the database using a form and $_POST. Some of these fields can be NULL and some cannot. This page will act as a sort of Admin page to allow a few of us to enter ads via a form on a page into the database (since no database currently exists). At this time, there are roughly 700 (ish) separate entries that need to be inputted into the new database created and they will be entered by myself and the admins of the former website.

    The host uses PHP Version 5.4.23 and the database is MySQL. Not sure what else you need to know, feel free to ask me any questions you might have. The website being updated is here and the new domain it is being migrated to is here. I can write the webpage code, once I know what to use for the variables to display.
    Once I have the code and verify it works as I need it to, I'll be MORE then happy to send a money order (or paypal pay direct), whichever you prefer. I can be reached either through these forums, or via email at admin@babes-behind-bars.com or xdramafreex@gmail.com

    The database connect file has been written, and to the best of my knowledge works fine.
    $database_driver = new mysqli_driver(); 
    $database_driver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT;
    $database = new mysqli('localhost', 'PASSWORD', 'USERNAME', 'DATABASE'); 
    Thank you for your consideration.
    Last edited by RodneyB; January 17th, 2014 at 07:24 PM. Reason: Typos and repair title
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Rep Power
    hi.. i am interested... please add my skype: ibnu.daqiqil

IMN logo majestic logo threadwatch logo seochat tools logo