Cereal,
Thanks for yor help on this. It was good to see your alternative approch to this issue, which I have now implemented to my code as it was more structured and concise.
Credit well deserved
Thanks

David

Hi Cereal,

I have produced the below code. Looks a bit long winded Does anyone know of a cleaner solution.

while ($rowProduct = mysql_fetch_array($productSQL))
    {
        echo $product[] = $rowProduct['POProductNet'];
    }

    if(is_array(@$_POST['Net']))
    {
        $files=array();
        foreach($_POST['Net'] as $file)
        {
            echo $files[] = basename($file);
        }
    }

    for ($count = 0; $count <= $productCount -1; ++$count){
        if ($files[$count] !== $product[$count]){
                // write data to db
        }

Thanks in advance

David

Hi Cereal,
Thanks for your reply
The aim of the compare is the user makes a change to the existing data via a form. The data is passed using $_post and I need to know what value has been changed so that the new value, is recorded in another table with additional data.

Would you still use a while loop to process the date or could you suggest an alternative method.

Thanks

David

Hi all,
I am trying to compare data from $_POST['Net'] which has 6 elements to check to see if the data has changed in the form when submitted.
Below is the Post array from form.

array(16) { ["Submitted"]=> string(4) "true" ["NetValue"]=> string(1) "0" ["ProductID"]=> array(6) { [0]=> string(5) "76458" [1]=> string(5) "76459" [2]=> string(5) "76460" [3]=> string(5) "76461" [4]=> string(5) "76462" [5]=> string(5) "76463" } ["Quantity"]=> array(6) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "2" [3]=> string(1) "1" [4]=> string(1) "1" [5]=> string(1) "1" } ["Nominal"]=> array(6) { [0]=> string(4) "5001" [1]=> string(4) "5001" [2]=> string(4) "5001" [3]=> string(4) "5001" [4]=> string(4) "5001" [5]=> string(4) "5001" } ["Department"]=> array(6) { [0]=> string(1) "4" [1]=> string(1) "4" [2]=> string(1) "4" [3]=> string(1) "4" [4]=> string(1) "4" [5]=> string(1) "4" } ["Unit"]=> array(6) { [0]=> string(5) "25.00" [1]=> string(5) "25.00" [2]=> string(5) "25.00" [3]=> string(5) "80.00" [4]=> string(6) "205.00" [5]=> string(6) "120.00" } ["Discount"]=> array(6) { [0]=> string(4) "0.00" [1]=> string(4) "0.00" [2]=> string(4) "0.00" [3]=> string(4) "0.00" [4]=> string(4) "0.00" [5]=> string(4) "0.00" } ["Net"]=> array(6) { [0]=> string(5) "25.00" [1]=> string(5) "50.00" [2]=> string(5) "50.00" [3]=> string(5) "80.00" [4]=> string(6) "205.00" [5]=> string(6) "120.00" } ["VATCode"]=> array(6) { [0]=> string(2) "T3" [1]=> string(2) "T3" [2]=> string(2) "T3" [3]=> string(2) "T3" [4]=> string(2) "T3" [5]=> string(2) "T3" } ["VAT"]=> array(6) { [0]=> string(4) "5.00" [1]=> string(5) "10.00" [2]=> string(5) "10.00" [3]=> string(5) "16.00" [4]=> string(5) "41.00" [5]=> string(5) "24.00" } ["ProductCount"]=> string(1) "6" ["NetTotal"]=> string(6) "530.00" ["VATTotal"]=> string(3) "106" ...

Thanks for looking found the solution on Stack overflow. needed to add this line data-container="body"
http://stackoverflow.com/questions/21938008/bootstraps-tooltip-moves-table-cells-to-right-a-bit-on-hover

Hi All,

I am trying to get tooltip to work when I hover text in a table. It does work but it produces an extra data table column. If you have any idea how I can stop this, please let me know.

Thanks

David

<script type="text/javascript">
    $(document).ready(function(){
    $('[data-toggle="tooltip"]').tooltip();   
});
</script>

<td class="tableBody"><?php echo $rowExceptionReport->POID; ?></td>
        <td class="tableBody"><?php echo $rowExceptionReport->POProductID; ?></td>
        <td class="tableBody"><?php echo htmlspecialchars($rowExceptionReport->ExportDate); ?></td>
        <td class="tableBody"><?php echo htmlspecialchars($rowExceptionReport->Quantity); ?></td>
        <td class="tableBody"><?php echo htmlspecialchars(substr($rowExceptionReport->Description,0, 100)); ?></td>
        <td class="tableBody"><?php echo htmlspecialchars($rowExceptionReport->WHLReference);?></td>
        <td class="tableBody" data-toggle="tooltip" data-placement="top" title="<?php echo $rowExceptionReport->NominalCode?>"><?php echo htmlspecialchars(substr($rowExceptionReport->NominalCode,0,20)); ?>...</td>

Good afternoon all,
The issue I am having is that when POST data values are looped through inside the while loop as each record is compared with the POST data and the database record for any changes.
For this test the data from the post is exactly correct. The if statment compares the data and displays this as not eaual when it is?
What I can see is happening from what I can see is that the out data when output is not in sync, but not sure how to resolve this
example
The data output fot the first loop potputs the following
Post data 33.30 - 32.40 DB Output
Post data 32.40 - 33.30 DB Output
The output should be like this when it is checked I am assuming.

Post data 33.30 - 33.30 DB Output
Post data 32.40 - 32.40 DB Output

Post Array data
This POST data needs to be compared to the recordes found in the Database using the while statement.

 `["ProductID"]=> array(2) { [0]=> string(5) "75849" [1]=> string(5) "75850" }` This is the two ID's
`["Net"]=> array(2) { [0]=> string(5) "33.30" [1]=> string(5) "32.40" }`

$productSQL = $Database->Execute("SELECT * FROM POProducts inner join PODepartments ON PODepartments.PODepartmentID = POProducts.PODepartmentID  inner join PONominalCodes ON PONominalCodes.PONominalCodeNumber = POProducts.POProductNominalCode   WHERE POID = " . $_GET['POID']. " ORDER BY POProductID ASC");
   while ($rowProduct = $Database->Records($productSQL)) {
   foreach($_POST['Net'] as $key) {// output the post array data
       if($key != $rowProduct['POProductNet']){//compare the results from the the  POST data and the Database output
            echo ...

Hi Pritaeas, Melvita,

Thank you both for your perseverance.

@ Melvita I have changed the code to

while($row = $mysqli->fetch_object($result)){

As advised

Having checked the password info by removing 1 charactor from the used password I get the usual unable to connect to the db.

I have added error checking with no error showing

ini_set('display_errors','on');
error_reporting(E_ALL);

db error check line
`mysqli = new mysqli($dbhost, $dbuser, $dbpass,$dbname) or die ("Error connecting to database");

if ($mysqli->connect_errno){
    printf("Connection failed: %s\n", $mysqli->connect_error);
    exit();
    }`

I changed mysql on line 11 as it is depreciated to
$page = mysqli_escape_string($_GET['page']); and I get 2 additional errors relating to this change

Warning: mysqli_escape_string() expects exactly 2 parameters, 1 given in /index.php on line 11

Warning: mysqli_escape_string() expects exactly 2 parameters, 1 given in /index.php on line 11

Notice: Use of undefined constant num - assumed 'num' in /index.php on line 9

Notice: Undefined index: page in /index.php on line 11

Fatal error: Call to undefined method mysqli::fetch_object() in /index.php on line 107

Thanks again

David

Hi Pritaeas,

Thanks for your assistance

$result = $mysqli->query("SELECT * FROM $tableName LIMIT $start, $limit");
print_r($result);

I have added the above code and i have no output

I have also added the print_r on the below execution which is on line 7 also no output

$query = $mysqli->query("SELECT COUNT(*) as num FROM $tableName");
$total_pages = $query;
print_r($query);

Thanks
David

Melvita,
I can see I have missed out the y in mysqli, so I have corrected this and I get the same error.

Fatal error: Call to a member function fetch_object() on a non-object in /index.php on line 167

Thanks again
David

Melvita,

Thanks for your reply
Fatal error: Call to a member function query() on a non-object in index.php on line 67

which is $query = $msqli->query("SELECT COUNT(*) as num FROM $tableName");

thanks again
david

Good day to you all,

I ham having an issue the the following error (Fatal error: Call to a member function fetch_result() on a non-object in on line 167) which is the while ($row = $result->fetch_object()) every way I try to change this another error crops up.

If yo can find the time to assist me, it would be appreciated.

Thanks in advance

connection page

<?php
$dbhost                         = "xxxxx";
$dbuser                         = "xxxx";
$dbpass                         = "xxxxxx";
$dbname                         = "xxx";

$mysqli =  new mysqli($dbhost, $dbuser, $dbpass,$dbname) or die ("Error connecting to database");
if ($mysqli->connect_errno){
    printf("Connection failed: %s\n", $mysqli->connect_error);
    exit();
    }
?>

Index

<?php
    include('connect.php'); 

    $tableName="country";       
    $targetpage = "index.php";  
    $limit = 10; 
    $query = $msqli->query("SELECT COUNT(*) as num FROM $tableName");
    $total_pages = $query;
    $total_pages = $total_pages[num];
    $stages = 3;
    $page = mysqli_escape_string($_GET['page']);
        if($page){
            $start = ($page - 1) * $limit; 
        }else{
            $start = 0; 
            }   
        // Get page data
        $result = $mysqli->query("SELECT * FROM $tableName LIMIT $start, $limit");
        // Initial page num setup
        if ($page == 0){$page = 1;}
            $prev = $page - 1;  
            $next = $page + 1;                          
            $lastpage = ceil($total_pages/$limit);      
            $LastPagem1 = $lastpage - 1;                    
            $paginate = '';
                if($lastpage > 1)
                {   
                    $paginate .= "<div class='paginate'>";
                    // Previous
                    if ($page > 1){
                        $paginate.= "<a href='$targetpage?page=$prev'>previous</a>";
                    }else{
                        $paginate.= "<span class='disabled'>previous</span>";   }
                    // Pages    
                    if ($lastpage < 7 + ($stages * 2))  // Not enough pages to breaking it up
                    {   
                        for ($counter = 1; $counter <= $lastpage; $counter++)
                        {
                            if ($counter == $page){
                                $paginate.= "<span class='current'>$counter</span>";
                            }else{
                                $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}                    
                        }
                    } ...

Hi

The correct wording for this is non www url redirect and i have found the answer
here
https://www.siteground.com/kb/how_to_redirect_www_urls_to_nonwww/

RewriteEngineOn
RewriteCond %{HTTP_HOST} ^watkins.co.uk [NC]
RewriteRule ^(.*)$ http://www.watkins.co.uk/$1 [R=301,L]

Thanks for those of you that looked at the post.
D

Hi

I am trying to redirect a url in the htaccess file.

RewriteEngineOn
RewriteRule ^wakins.co.uk$ http://www.watkins.co.uk [R=301,L]

and I have also tried this

RewriteEngineOn
RewriteRule ^/wakins.co.uk$ http://www.watkins.co.uk [R=301,L]

Thanks in advance

D

Hi all, I am trying to compare output from DB

The code below works on 1 check, but I require to do this on multiple products like so if rowProduct("GRPCODE") <> "Cross Hire" or rowProduct("GRPCODE") <> "Boiler Ancillaries" then etc

but the above line does not work as I have coded it? What is the problem with the code.

Thanks in advance

if rowProduct("GRPCODE")  <> "Cross Hire" then
                                ' Elimination unwanted code
                                if not rowStock.eof then
                                    ' stock found
                                      do while not rowStock.eof
                                        ' loop through stocl
                                        if instr(RemoveItems, "," & rowStock("ITEMNO") & ",") = 0 then
                                            ' item not removed
                                            StockCount = (StockCount + 1)
                                            if rowStock("QTYHIRE") <> "0" then
                                                ' on hire
                                                StockOnHire = (StockOnHire + 1)
                                            end if' end QTYHIRE
                                            if rowStock("QTYALLOC") <> "0" then
                                                ' allocated  
                                                StockAllocate = (StockAllocate + 1)
                                            end if ' end QTYALLOC if
                                        end if
                                        rowStock.movenext
                                      loop ' end do while
                                end if
                            end if

thanks

Thanks

Hi Diafol,
Thanks for your reply Diafol. I am not making myself very clear and I appolgise in adavace.

I am pulling the following data from the DB POHaulageLossApproval which is an INTEGER see image

2fb614a319f75c809757bb46d04463b8

Once the checkbox has been selected I am looking to pass a value that will tell me the POID so that I can update DB value POHaulageLossApproval

I will then test for it at this point and udate the sql table.

 <?php 
   if (isset($_GET['PO_Approved'])){
         // udate POHaulageLossApproval in db
        exit();
    }
  ?>

As I am only passing the 2 parameters, how can I add a value to pass in the string to test checkbox name/value

Thanks Again

Hi Diafol, thanks for your reply.
I agree the UserID is in sessions. So to test if checkbox has been submitted
I should test like so?

POID is the DB PK and I need to pass that information and how would I pass this value PO_Approved. I could place form tags around this and pass as a form, this method does not seem to apply then you check the checkbox?

I will look a ajax also.

Any furthe advice appreciated even if it is the incorrect way to do this?

Thanks

David

<?php 
    if (isset($_GET['PO_Approved'])){
        echo "SET";// udate approval
        exit();
    }
 ?>

Hi All, I am currently trying to update a check box . Then pass the data back through the same page and if set update DB. The code is long so I shall be as concise as possible.

I have pulled the data from the DB and I am using a check box to submit and test if checkbox has been submitted using isset $_POST on checkbox. I have also used debug on GET and REQUEST and I am not sure why it does not work.

Any assistance would be appreciated.

Thanks in advance

 <?php 
    if (isset($_POST['checkbox'])){
        echo "SET";// udate approval
        exit();
    }
 ?>

 <td class="centre">

    <input class="checkboxnostyle" id="PO_Approved<?= $rowProduct['POID']; ?>" name="PO_Approved<?= $rowProduct['POID']; ?>" onClick="location.href='/sons/approval.php?POID=<?= $rowProduct['POID']; ?>&UserID=<?= $_SESSION['UserID']; ?>';" type="checkbox" value="PO_approved" />

 </td>

Hi diafol, not expected at all. I replaced the code with my original settings to help make it clear what I had started with.(no offence intended)

This was the warning that I received.

Thanks

Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in /home/djenning/public_html/test/includes/functions/database.php on line 22
OK
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in /home/djenning/public_html/test/includes/functions/database.php on line 28

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/djenning/public_html/test/includes/functions/database.php on line 36

<?php 
    /*-------------------------------------------------
    This class contains generic database functions to 
    view, add, edit and delete all facets of a database
    -------------------------------------------------*/

    require_once ("sitesettings.php");

    class Database extends SiteSettings {
        var $Query;
        var $Connection;

        function Database() {
            $Settings = SiteSettings::SettingValues();

            $Hostname = $Settings['DB-Hostname'];
            $Username = $Settings['DB-Username'];
            $Password = $Settings['DB-Password'];
            $Database = $Settings['DB-Database'];

            $this->Connection = mysqli_connect($Hostname, $Username, $Password);
            mysqli_select_db($Database);
            register_shutdown_function(array(&$this, "close"));
        }

        function Execute($SQL) {
            $this->Query = $SQL;
            return mysqli_query($SQL, $this->Connection);
        }

        function Records($SQL) {
            return mysqli_fetch_array($SQL);
        }

        function RecordCount($SQL) {
            return mysqli_num_rows($SQL);
        }

        function Close() {
            mysqli_close($this->Connection);
        }
    }
?>

Hi I am trying to convert the following mysql function to mysqli.

Thanks in advance

David

<?php 
    /*-------------------------------------------------
    This class contains generic database functions to 
    view, add, edit and delete all facets of a database
    -------------------------------------------------*/

    require_once ("sitesettings.php");

    class Database extends SiteSettings {
        var $Query;
        var $Connection;

        function Database() {
            $Settings = SiteSettings::SettingValues();

            $Hostname = $Settings['DB-Hostname'];
            $Username = $Settings['DB-Username'];
            $Password = $Settings['DB-Password'];
            $Database = $Settings['DB-Database'];

            $this->Connection = mysql_connect($Hostname, $Username, $Password);
            mysql_select_db($Database);
            register_shutdown_function(array(&$this, "close"));
        }

        function Execute($SQL) {
            $this->Query = $SQL;
            return mysql_query($SQL, $this->Connection);
        }

        function Records($SQL) {
            return mysql_fetch_array($SQL);
        }

        function RecordCount($SQL) {
            return mysql_num_rows($SQL);
        }

        function Close() {
            mysql_close($this->Connection);
        }
    }
?>

Hi Keloa,

I think this what you are asking for? You created 2 tables only 1 was required. Also make sure you use the th and td correctly.

You may have to change the table width.

See how you get on with it
d

<?php ?>
<table border="1" width="40%">
<tr>
    <th>
        <center><h5>order</h5></center>
    </th>
    <th>
        <center><h5>Tracking Number</h5></center>
    </th>
</tr>
<tr>
    <td>
        <?php
        $sql_order = "SELECT * FROM serv WHERE username='".$username."'";
        $query = mysql_query($sql_order);
        while ($order = mysql_fetch_object($query))
        {
             echo "$order->title";
        }
        ?>
     </td>
     <td>
        <?php echo "$order->tracking_number";  ?>
    </td>
<tr/>
</table>

The following code is producing this error Microsoft VBScript compilation error 800a03f6 Expected End
followed by /stock/availability-quick/availability2.asp, line 130

I think it is a if else error. I have looked over the code and i don't see the error and would benefit from an expert pair of eyes to look over it.

Thanks in advance

David

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../includes/functions/insphire.asp"-->
<!--#include file="../../includes/functions/logaccess.asp"-->
<!--#include file="../../includes/functions/stock.asp"-->
<%
    if request("Allow") = "f875eba08594178509bd3482dc0294" then
        ' security check passed
%>
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
                <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                    <title>Administration - Stock - Status</title>
                </head>
                <body>

                <%
                    if not rowAuto.eof then
                        ' automatic stock take found
                %>

                <table cellspacing="3" class="mbottom new" width="100%">
                    <tr>
                        <th width="33%">Date</th>
                        <th width="33%">Status</th>
                        <th width="43%">Status Information</th>
                    </tr>
                <%
                        do while not rowAuto.eof
                            ' loop through automatic stock take
                            StatusInfo = "Available"
                            StatusText = rowAuto("StockTakeDepot") & "&nbsp;"

                            if rowAuto("StockTakeStatus") = "1" then
                                ' item on hire
                                StatusInfo = "On Hire"
                                StatusText = rowAuto("StockTakeContract") & ", " & rowAuto("StockTakeCompany")
                            end if
                %>
                    <tr>
                        <td><%= rowAuto("StockTakeDate") %></td>
                        <td><%= StatusInfo %></td>
                        <td><%= StatusText %></td>
                    </tr>
                <%
                            rowAuto.movenext
                        loop
                %>
                </table>
                <%
                    else
                        ' no automatic stock take found
                %>
                <h2 class="centre mbottom">There are currently no automatic stock takes for <%= request("ItemNo") %>.</h2>
                <%
                    end if

                    if not rowManual.eof then
                        ' manual stock take found
                %>
                <h2 class="mbottom mtop">Manual Stock Records for <%= request("ItemNo") %></h2>
                <table cellspacing="3" class="mbottom new" width="100%">
                  <tr>
                    <th width="15%">Date</th>
                    <th width="10%">Taken By</th>
                    <th width="10%">In Stock?</th>
                    <th width="10%">Depot</th>
                    <th width="55%">Notes</th>
                  </tr>
                <%
                    do while ...

All sorted missed of the variable name after the ? in link.

Thanks for looking

David

<td height="30"><a href="http://admin.boilerrentalservices.co.uk/availability.php**?Product=**<%= rowProduct("GRPCODE") %>"><%= rowProduct("GRPCODE") %></a></td>

Hi All, I am tring to capture the data being passed from an ASP page.

<td height="30"><a href="http://admin.boilerrentalservices.co.uk/availability.php?<%= rowProduct("GRPCODE") %>"><%= rowProduct("GRPCODE") %></a></td>

using VAR_DUMP($_GET) in the PHP page which produces this

array(1) { ["AHU-100-200"]=> string(0) "" }

How can I extract this 'AHU-100-200' data in a usable form and use to search a Database.

Thanks in advance

David

Thanks for your help JorgeM, converting the value from a string to an Integer value did the trick.

Thanks

David

Hi JorgeM, thanks for your reply.

QTYALLOC is holding a values of 0, 1 or 2 rather than add 1 to StockAllocate = (StockAllocate + 1)

I want to add the value 2 to (StockAllocate + QTYALLOC) so I put the value of QTYALLOC into a variable called order ie order= rowStock("QTYALLOC") and then add the value to (StockAllocate + order) so when the value is a 2 it will increment (StockAllocate + 2) this didn't work

below is how I think the process should work and how I have written it, but does not seem to work.

if rowStock("QTYALLOC") <> "0" then
    ' allocated
    order= rowStock("QTYALLOC")
    StockAllocate = (StockAllocate + order)
end if

I hope that helps

Fhanks in advance

David

Hi All, I am a new user to ASP and would like to add a to an accumalted value.

The value stored in QTYALLOC can be a 1 or a 2 but currently the code will only add increment by 1, but what I am trying to do is increment by the value of QTYALLOC. I had placed order in the increment counter (StockAllocate + 1) like so (StockAllocate + 1) but this did not seem to work. My syntax mak not be correct.

What I have tried is not working. Any assistance would be appriciated.

if rowStock("QTYALLOC") <> "0" then
    ' allocated
    order= rowStock("QTYALLOC")
    StockAllocate = (StockAllocate + 1)
end if

Thanks in advance

David