broj1 356 Humble servant Featured Poster

Each input on your form has to have a unique ID so you can refer to it. Also edit links have to have uinque IDs. You can use an ID from the database data or something else.

<input name="tx_name" type="text" id="tx_id-<? echo $data['id']; ?>" size="35" value="<? echo $data['title']; ?>"/>

<a href="#" class="editname" id="<? echo $data['id']; ?>">Edit</a>

Now you can catch the onclick event of edit link and read record ID from it:

$(".editname").click(function() {

    var recordId = $(this.attr('id'));

    // use recordId to access input fields
    var inputValue = $(('txt_id-' + recordId)).val(); // or something like that
    ...

EDIT: I have done several edits in the code so make sure you refresh to the last version.

The code above might be a bit wobly but you get the principle. I haven't tested it.

broj1 356 Humble servant Featured Poster

The query itself looks OK. Please double check if table name is file_records, and field names are also spelled correctly. Please paste the displayed query into the SQL tab of phpmyadmin and test if it works OK. And do not to remove the die() line.

Also change line 67 to include a check:

if(!mysql_select_db($MySql_databasename,$dbconn)) {
    die("Could not select database");
}

Do similar checks when connecting to the database and when performing queries. And temporary remove the @ form the mysql_query command on line 68 so you can see possible error messages.

broj1 356 Humble servant Featured Poster

If you ask me, none of the fields here are binary:

@mysql_query("INSERT INTO file_records (file_name, file_title, file_size, uploaded_date) VALUES ('$NewFileName', '$FileTitle',$FileSize,'$uploaded_date')");

file_name and file_title should be strings, file size could be integer, uploaded date should be integer (if timestamp) or date. But if you wanted to store binary file in database the table field should be declared binary or varbinary. The query itself does not change.

broj1 356 Humble servant Featured Poster

Put this code immediately after line 68:

die("INSERT INTO file_records (file_name, file_title, file_size, uploaded_date) VALUES ('$NewFileName', '$FileTitle',$FileSize,'$uploaded_date')");

It will display the query as it gets contructed using the variables. Paste it into phpmyadmin and check for errors. You can also post it here.

BTW: none of the data in the query is binary I guess. You are not inserting the file contents to database, are you (just looking at the title of the post)?

broj1 356 Humble servant Featured Poster

Do have any links or examples that show how mysqli_num_rows() & mysqli_fetch_assoc() works in OOP style.

There are good examples on php.net (see the Examples section after the definitions):

Class initialization
http://www.php.net/manual/en/mysqli.construct.php

Querying (includes code for class initialization)
http://www.php.net/manual/en/mysqli.query.php

Getting number of rows (includes code for class initialization and querying)
http://www.php.net/manual/en/mysqli-result.num-rows.php

php.net site at first look seems to be a bit unfriendly to new users due to a lot of technical information. But once you get used to it you find it the best resource for PHP. Always have look at the examples section and See also section. User comment can be interesting, too.

LastMitch commented: Thanks for the resources! +10
broj1 356 Humble servant Featured Poster

Considering the above, the Posts class should be something like:

class Posts {

    private $db;

    public function __construct($mysqli) {

        include 'dbConnMysqli.php';
        $conn = new dbConnMySqli;
        $this->db = $conn->getmysqliObject();
    }

    public function getPosts(){

        $query = "SELECT * FROM posts";
        $sql = $this->db->query($query);
        $result = $sql->fetch_assoc();
        $row = $result->num_rows;
        return $result;
    }
}
broj1 356 Humble servant Featured Poster

There are many questions here, I hope I manage to follow the main track :-). I will do it in couple of posts so we stay organized (in other words: you can not swallow a whole watermellon, you have to cut it in pieces).

I think foo_mysqli class is unnecessary here for two reasons: 1. you are not really adding anything to the mysqli class (which is a purpose of extending an existing class) but that would be okay; 2. you are not using it anywhere, you are using mysqli class in other scripts.

I am not saying that you should not do it this way. You can extend mysqli but then try to add some useful functionality to it like various ways of handling errors (display the errors during development, log the errors in production, provide default connection parameters etc). The following is the class I use for connecting and you can use it as an example (see the comments in it):

/**
 * This class establishes a connection to Mysql database using mysqli extension
 */
class dbConnMySqli
{
    // connection parameters
    protected $host = '';
    protected $user = '';
    protected $pass = '';
    protected $db = '';

    // mysqli object
    protected $mysqliObj = null;

    /**
     * Initialize connection parameters if set
     * 
     * @param string host
     * @param string $db_user
     * @param string $db_pass
     * @param string $db_name
     */
    public function __construct(
        $db_host = null, 
        $db_user = null, 
        $db_pass = null, 
        $db_name = null
    )
    {
        if($db_host && …
broj1 356 Humble servant Featured Poster

I just want to know the best way of connecting beside PDO. So OOP with MYSQLI is good.

In most cases PDO is the best way to do it, but you need at least PHP 5 for it, it won't work in older versions. The good side is that it somehow makes you independent of database vendor since it supports quite a many of them, so you can change a database and still use the same code. But it won't support all missing or proprietary functionanities of different databases. There are abstraction layers that do that better (I used PEAR MDB2).

If you plan to use only MySql then mysqli exstension is equaly good.

The OOP mode is preferred (from my point of view).

Both OOP and procedural modes do their job OK. I prefer OOP way just because most (if not all) frameworks and abstraction layers are OOP and is just good if you are familiar with this approach and use it consistently.

$result = mysqli_query($link, "SELECT * FROM posts")

This is mysqli used in procedural way. There is also a OOP version of this function:

$mysqli->query("SELECT * FROM posts");

See examples of both approaches here.

broj1 356 Humble servant Featured Poster

You changed the mysql connection function from OOP mode to procedural mode. The OOP mode initialized a mysqli object which has methods you can call. But the procedural mode does not initialize the object so you can not call it's methods (i.e the query method). Why did you do that?. The OOP mode is preferred (from my point of view).

// for this to use you need a mysqli object
$sql = $mysqli->query("SELECT * FROM posts") or die("Problem with query");

If you do not have a mysqli object (i.e. you do it procedural style), your connection function has to return the link.

function myDbObj(){

    // this does not have to be global
    global $mysqli;

    //connect to server and select database
    $link = mysqli_connect('host', 'user', 'password', 'db');

    //if the connection fails, stop script execution
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();

    // otherwise return the link
    } else {
        return $link;
    }
}

Then you shoot the query:

$result = mysqli_query($link, "SELECT * FROM posts")

Haven't tested the code, see it here: http://www.php.net/manual/en/mysqli.query.php.

broj1 356 Humble servant Featured Poster

And this is the whole script:

$username = "username";
$password = "password";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br><br>";
//select a database to work with
$selected = mysql_select_db("database",$dbhandle)
or die("Could not select database");

function getStatesArrayString() {

    //choose the table and return records
    $result = mysql_query("SELECT id, state,country_id FROM state ORDER BY country_id");

    // initialize temporary string for one row
    $tempStr = '';

    // initialize the string that will be returned
    $retStr = '';

    // current value of country_id
    $country = null;

    //get group
    while($row = mysql_fetch_assoc($result)) {

        // we are starting new country
        if ($row['country_id'] != $country) {

            // echo the array string only when $country is not null
            // (which is only on beginning)
            if($country != null) {

                // first eplace trailing , with ]
                $tempStr = substr_replace($tempStr, ']', -1, 1);

                // now add the tempoprary string to return string
                // semicolon and newline chars were added for javascript
                $retStr .= $tempStr . ";\n";
            }

            $country = $row['country_id'];
            $tempStr = "[$country] = parent_array [";
        } 

        // we are appending to the existing country
        $tempStr .= "'{$row['id']}|{$row['state']}',";                

    }

    // once finished return the return string
    return $retStr;
}

// test what function returned
echo '<pre>' . getStatesArrayString() . '</pre>';

//end of group
$db = null;
echo "<br>Fetched data successfully\n<br>";
mysql_close($conn);
?>
broj1 356 Humble servant Featured Poster

The output I get is:

[6] = parent_array ['70|Andorra la Vella'];
[8] = parent_array ['3|Abu Dhabi','16|Ajman'];
[19] = parent_array ['79|Antwerpen'];
[24] = parent_array ['32|al-Manama'];
[31] = parent_array ['60|Amazonas','48|Alagoas','5|Acre','59|Amapá'];
[38] = parent_array ['50|Alberta'];
[41] = parent_array ['78|Antofagasta'];
[42] = parent_array ['72|Anhui'];
[46] = parent_array ['77|Antioquia'];
[55] = parent_array ['71|Anhalt Sachsen'];
[60] = parent_array ['74|Annaba','53|Alger'];
[62] = parent_array ['26|al-Daqahliya','27|al-Faiyum','28|al-Gharbiya','42|al-Sharqiya','51|Aleksandria','38|al-Qalyubiya','33|al-Minufiya','25|al-Buhayra','34|al-Minya'];
[65] = parent_array ['67|Andalusia','88|Aragonia'];
[67] = parent_array ['61|Amhara','7|Addis Abeba'];
[71] = parent_array ['56|Alsace','86|Aquitaine'];
[76] = parent_array ['11|Adzaria [Atšara]','1|Abhasia [Aphazeti]'];
[77] = parent_array ['100|Ashanti'];
[97] = parent_array ['4|Aceh'];
[98] = parent_array ['68|Andhra Pradesh'];
[101] = parent_array ['90|Ardebil'];
[102] = parent_array ['20|al-Anbar','44|al-Tamim','43|al-Sulaymaniya','35|al-Najaf','37|al-Qadisiya'];
[105] = parent_array ['2|Abruzzit','82|Apulia'];
[107] = parent_array ['45|al-Zarqa','62|Amman'];
[108] = parent_array ['15|Aichi','81|Aomori','18|Akita'];
[109] = parent_array ['84|Aqtöbe','54|Almaty','55|Almaty Qalasy'];
...
broj1 356 Humble servant Featured Poster

First to let you know that I do not know Joomla at all.

You can prepare a function that will return the string, representing the arrays, appropriate for your javascript. My suggestion is the following:

function getStatesArrayString() {

    //choose the table and return records
    $result = mysql_query("SELECT id, state,country_id FROM state ORDER BY country_id");

    // initialize temporary string for one row
    $tempStr = '';

    // initialize the string that will be returned
    $retStr = '';

    // current value of country_id
    $country = null;

    //get group
    while($row = mysql_fetch_assoc($result)) {

        // we are starting new country
        if ($row['country_id'] != $country) {

            // echo the array string only when $country is not null
            // (which is only on beginning)
            if($country != null) {

                // first eplace trailing , with ]
                $tempStr = substr_replace($tempStr, ']', -1, 1);

                // now add the tempoprary string to return string
                // semicolon and newline chars were added for javascript
                $retStr .= $tempStr . ";\n";
            }

            $country = $row['country_id'];
            $tempStr = "[$country] = parent_array [";
        } 

        // we are appending to the existing country
        $tempStr .= "'{$row['id']}|{$row['state']}',";                

    }

    // once finished return the return string
    return $retStr;
}

This function will need a database connection already established (or you can add that to the function). The function will return a string that will represent a javascript code that assigns the to the array. You can change the function once the database changes.

To test the function do the following:

 echo '<pre>' . getStatesArrayString() . '</pre>';
broj1 356 Humble servant Featured Poster

Can you post the state table contents in a CREATE TABLE / INSERT INTO statement (you get it by exporting the table into SQL format from phpmyadmin). Also please post the whole php/html code. I am sort of guessing whatyou want but would prefer to test it in my environment. You can also PM the code if you prefer.

broj1 356 Humble servant Featured Poster

Insert some debug code say after line 89:

echo "Username query: $query_checkuser<br />";
echo "Password query: $query_checkpswd<br />";
echo "Entered password: $password<br />";
echo "Password in the DB: $p_password<br />";

and check whether queries and values are correct.

broj1 356 Humble servant Featured Poster

Can you post the state table contents in a CREATE TABLE / INSERT INTO statement (you get it by exporting the table into SQL format from phpmyadmin). Also please post the whole php/html code. I am sort of guessing whatyou want but would prefer to test it in my environment. You can also PM the code if you prefer.

broj1 356 Humble servant Featured Poster

When you call the function you have to pass it a parameter.

// this is a function declaration only
function getPosts($mysqli) {
    $sql = $mysqli->query("SELECT * FROM posts") or die("Problem with query");
    while($row = mysqli_fetch_assoc($sql)) {
        echo $row['Content'];
    }
}

// now, to use the function first initialize the mysqli object
$myDbObj = new $mysqli('host', 'user', 'password', 'db');

// then call the function with the object as a parameter
getPosts($myDbObj);
broj1 356 Humble servant Featured Poster

The function does not know about the mysqli object. You should either pass it as a parameter or initialize mysqli within the function (as lastMitch suggested).

$mysqli = new $mysqli('host', 'user', 'password', 'db');

function PM($mysqli) {
    $query = "SELECT * FROM posts";
    $result = mysqli_query($mysqli, $query) or die(mysqli_error($mysqli));
    while($row = mysqli_fetch_assoc($query)) {
        echo $row['Content'];
    }
}

or

$db = new $mysqli('host', 'user', 'password', 'db');

function PM($db) {
    $sql = $db->query("SELECT * FROM posts") or die("Problem with query");
    while($row = mysqli_fetch_assoc($sql)) {
        echo $row['Content'];
    }
}
broj1 356 Humble servant Featured Poster

It was just an example since I am not sure if I understood your code. I will try to do an example with your code but if it doeasn't work we'll try to clarify it then.

//choose the table and return records
$result = mysql_query("SELECT id, state,country_id FROM state ORDER BY country_id");
$string .= '"'.$val.'", ';
$country = null;

// initialize $str
$str = '';

//get group
while($row = mysql_fetch_assoc($result)) {

    if ($row['country_id'] != $country) {

        // I do not know why these are
        echo '<br><br>';

        $str .= "[".($row['country_id'])."] = parentarray [";

        $country = $row['country_id'];
    }

    // get list
    $str .= "'".$row['id'] . "|" . $row['state']."',";
}

// replace trailing , with ]
$newStr = substr_replace($str, ']', -1, 1);

echo $newStr;

//end of group
$db = null;
echo "<br>Fetched data successfully\n<br>";
mysql_close($conn);
?>
broj1 356 Humble servant Featured Poster

i havent sleptbecause i started working on this @ midnigh

No worries mate. Just take it easy. Sometimes it is good to take a break for 10 mins or so.

broj1 356 Humble servant Featured Poster

For images you do not have to store the sizez (you could if you wish). You can get them using getimagesize function instead.

// calculate the width and the height or read them from db
$width = ...
$height = ...

// use the dimensions in the code
$spannedRow = '<td rowspan=2 colspan=2 height="' . $height . '" width="' . $width . '">';
$spannedRow .= '<script type="text/javascript" language="javascript" src="' . $jsCode;
$spannedRow .= '"></script></td>';
$normalRow = '<td height="' . $height . '" width="' . $width . '">';
$normalRow .= '<script type="text/javascript" language="javascript" src="' . $jsCode;
$normalRow .= '"></script></td>';
broj1 356 Humble servant Featured Poster

except i do need to figure out how to define what page it takes you to, and where that page is.

<?php
// define the target page using some logic
$target_page = 'some_page.php';
?>

<form method="post" action="<?php echo $target_page; ?>">
<input type="submit" name="submit" value="Click me">
</form>
broj1 356 Humble servant Featured Poster

Its a 40+ MB tar.gz i can ftp you if you let me... for the template that runs my live site.

No need to send entire site code. With each question just post the relevant code snippet.

broj1 356 Humble servant Featured Poster

Can you please explain more? or maybe even provide a basic example?

http://www.jquery4u.com/function-demos/ajax/#
http://tutorialzine.com/2009/09/simple-ajax-website-jquery/
etc...

broj1 356 Humble servant Featured Poster

Very many questions in such a short time. I am getting lost :-)

broj1 356 Humble servant Featured Poster

can you change the heading of this thread to "Create Ad Space" instead of "create a mysql polulated dropdown menu"

I cant't do that, I am not the admin.

broj1 356 Humble servant Featured Poster

To generate table just do something like:

$jsCode = 'http://www.redacted.net/redactedredactedredacted?target=_blank&mouseover=Y';

$spannedRow  = '<td rowspan=2 colspan=2 height="125" width="125">';
$spannedRow .= '<script type="text/javascript" language="javascript" src="' . $jsCode;
$spannedRow .= '"></script></td>';

$normalRow  = '<td height="125" width="125">';
$normalRow .= '<script type="text/javascript" language="javascript" src="' . $jsCode;
$normalRow .= '"></script></td>';

echo '<table align="center" cellpadding="0" cellspacing="0">';

// if you read data from the sb do the while loop otherwise do the for loop
while(<reading rows == true>) {

    echo '<tr>';
    echo $spannedRow;
    echo $spannedRow;
    echo $normalRow;
    echo $normalRow;
    echo $normalRow;
    echo $normalRow;
    echo '</tr>';
}

echo '</table>';

This is just an example. You have to apply your logic to it.

broj1 356 Humble servant Featured Poster

You have to be familiar with ajax to use it. The simplest way is to use jquery. If you are not familiar with it then I strongly suggest you learn it first, otherwise you will be dependend on others to help you with each issue and noone can guarantee a quick response. And easiest way to help someone is to see the code.

So I want to populate the javascripts in the cells, from a database.

What is the javascript code?

I also want the ads to display properly, by having PHP magically re-draw my tables

You can do that easily with PHP. What is the code for the table?

broj1 356 Humble servant Featured Poster

IS there a nice and easy way to re-draw said tables, based on the output,

There is nice and easy way if you do not mind reloading the page. Just send the new values using a form and GET or POST method.

If you do now want to reload the page you can use ayax but that is not that easy anymore. You should be familiar with ajax for this.

broj1 356 Humble servant Featured Poster

It still displays the text Partners to the left of the menu... im assuming its supposed to be there. Also that it is coming from <label for="partner">Partner</label>.

Yes.

Question #1-B: May i use things like <h1> like i can with <a href= ?

Sorry, I do not understand the question. Please explain.

broj1 356 Humble servant Featured Poster

Instead of echoing the parts of the string asign it to a string variable and use substr_replace function, i.e.:

$str = "parentarray ['136|Balkhs','481|Herat','564|Kabol','979|Qandahar',";
$newStr = substr_replace($str, ']', -1, 1);
broj1 356 Humble servant Featured Poster

See my post above.

broj1 356 Humble servant Featured Poster

OK, so put back the dot you removed and declare the $partner_block variable before the while loop (so you can later append to it):

$partner_block = '';
while($partner = mysql_fetch_array( $partners ))
{
    $partner_id = $partner['id'];
    $partner_name = $partner['name'];
    ## Now, let's assign the partner inside the option form tags.
    ## the partner named bundagle and somewhere should be now inside the option tags.
    $partner_block .= '<OPTION value="'.$partner_id.'">'.$partner_name.'</OPTION>';
} ## end while loop
broj1 356 Humble servant Featured Poster

If the variable has not been declared yet, you can not append to it. You can asign to it (with asigning you declare the variable). So just remove the dot (appending operator):

$partner_block = '<OPTION value="'.$partner_id.'">'.$partner_name.'</OPTION>';

That will remove the error in line 22 but I do not know if that is all that is needed for your code to work correctly. Tell us how it goes.

broj1 356 Humble servant Featured Poster

You are appending a string to a variable $partner_block that is not defined anywhere else (at least not in the code you posted):

$partner_block .= '<OPTION value="'.$partner_id.'">'.$partner_name.'</OPTION>';
broj1 356 Humble servant Featured Poster

You are welcome. Do not forget to mark as solved when solved.

broj1 356 Humble servant Featured Poster

There are two small glitches:

  1. if there are no results in the list yet, you get a small div displayed anyway.
  2. if you have three characters and delete one, two or three, the list won't update

That is why I corrected the javascript code to the following:

$(document).ready(function() {

    $('.dropdown').hide();

    $('.autosuggest').keyup(function (e) {

        // we also have to check if user is deleting entries
        // in that case less than 3 characters also trigger suggestion
        isDelete = false;

        // if delete or backspace were pressed, 
        // less than 3 characters also trigger suggestion
        if( e.which == 8 || e.which == 46) {

            isDelete = true;;
        }

        var search_term = $(this).attr('value');

        // if search term does not exist or
        // if it is less than 3 chars and user hasn't deleted any chars
        // then hide the list
        if(
            search_term.length == 0 || 
            (search_term.length < 3 && isDelete == false)
        ) {

            $('.dropdown').hide();

        } else {

            $('.dropdown').show();
        }


        // check if we have at least 3 characters or user is deleting characters
        if(search_term.length >= 3 || isDelete == true) {

            // read the values of the select elements (drop downs)
            // read the value of category
            var category=$('#category').attr('value');

            // this is the conditions you will post over to the searchApp.php script
            // assembled here for clarity
            var conditions = {

                'search_term' : search_term,
                'category' : category
            };

            // alert(conditions.toSource());

            // post the conditions over to the searchApp.php script
            $.post('ajax/searchApp.php', conditions, function(data) {

                //alert(data);
                $('.result').html(data);
                /*
                // you can …
LastMitch commented: Nice Work! +10
broj1 356 Humble servant Featured Poster

Well it is only the css that has to be mended. It works for me if the div with the class="dropdown" has position absolute and high z-index value:

.dropdown {
    position: absolute;
    z-index: 10000;
}
broj1 356 Humble servant Featured Poster

Post the complete html, css and ajax code, plus the database structure with some data (in CREATE TABLE... and INSERT INTO.. SQL statements, so I can just copy them to phpmyadmin) and I can have a look at it tomorow if time permits. You can also send it to my PM if you prefer.

broj1 356 Humble servant Featured Poster

I am not an expert in CSS so I will give it a try but I do not claim I am 100% right.

JQuery function puts the result in the ul element. For this reason the ul element grows and pushes the content below it further down. If you want it not to affect the contents around it the position property should be set to absolute while the position of the parent element (div with class=dropdown) should be set to relative (so the absolute works on ul). Also the z-index property of the ul element should be set to something high, say 10000, so you make sure the autosuggested list is above all other elements.

broj1 356 Humble servant Featured Poster

So you are saying that the dropdown div is pushing the content down to make room for autosuggestions? If yes, post the CSS for the dropdown class.

broj1 356 Humble servant Featured Poster

You have done it OK, only a double quote (as part of html attribute value) is missing after 240.

echo('<embed src="flash/' . rand(1, 5) . '.swf" type="application/x-shockwave-flash" width="320" height="240"></embed>');
broj1 356 Humble servant Featured Poster

Check if $_SESSION['access_level'] is really 220. You can also try to put the line

header('location:borangK8.php');

on top of the script to see whether redirection works.

Also make sure no html (not even a space) is sent before header() function. Check your script and included files for output.

broj1 356 Humble servant Featured Poster

If you do not have many results for each div you can also fake pagging. You read all the product data but display only a portion of it and hide the rest (using CSS display:none). On clicking page links you can then unhide another portion and hide previous.

broj1 356 Humble servant Featured Poster

Yes, but then you have to forget all the ayax stuff. This means that on each click (either on one of the links for categories or links for pages) the wholepage will be refreshed/reloaded. This in your case is OK since about 90% of page contents gets refreshed anyway.

To use Pager for paginating DB results see this link (from the maintainer of the package) and use method #2 which is simpler.

broj1 356 Humble servant Featured Poster

The only thing I can come up with is that the url might be incorrect. Have you checked spelling?

broj1 356 Humble servant Featured Poster

If you use this plugin you have to do a few more things:

  • get the number of total pages for that particular product (using COUNT(*) WHERE product_id=...) and store it into items varialble
  • prepare a php script that will return the records for one page, using itemsOnPage parameter (or modify existing script)
  • use onPageClick function which will call above mentioned php script to fetch pages

But documentation for this plugin is not very comprehensive. So maybe you try this one, which has a nice tutorial along with it.

I have never done any jquery/ajax pagination so I can not give you any finished code. I used PEAR Pager class for this purpose and it was doing it's job very well.

broj1 356 Humble servant Featured Poster
broj1 356 Humble servant Featured Poster

It would be also expected that you logout visitors with access level less than 100, not greater than 100. The higher the acces level the more rights the user has. Like below:

if(!isset($_SESSION['access_level']) || $_SESSION['access_level'] < 100) {
broj1 356 Humble servant Featured Poster

Weel, it's time to check the UPDATE sql statement which I guess might be in update.php. Can you post it please.

BTW: I'll probably won't be able to reply sooner than tomorrow morning.

broj1 356 Humble servant Featured Poster

OK, try this in Update.php:

<input type="hidden" name="customer_id" class="customer_id" value="<?php echo $customer_id; ?>">

$customer_id actualy holds your customer ID (and not $customer['customer_id'] as in my previous post). My mistake, sory, it's a lot of code and sometimes hard to follow.