Jump to content

Recommended Posts

ChartTest2.php is working fine. It list up the oldest order in the database from the query. The problem arrise when I execute the code  <input type=button onClick="parent.location='bekrefte.php'" value='Bekrefte ordre'>. This takes me to bekrefte.php that should update the one order that chartTest2.php list to the screen and change the admin_status from 5 to 1(from unconfirmed to confirmed) in the DB. The result is that one order in the DB change value, but not the one that I want(the order that chartTest2.php list to the screen(browser)). I think the problem is either with the UPDATE query or/and with the "include 'chartTest2.php'; I have never used include before, so all help with this and the rest is much appreciated :-)

 

 

 

 ChartTest2.php

<?php



$conn = mysql_connect("localhost", "root", "");



if (!$conn) {

    echo "Unable to connect to DB: " . mysql_error();

    exit;

}



if (!mysql_select_db("motecopy_mote")) {

    echo "Unable to select mydbname: " . mysql_error();

    exit;

}

//OR status = 'authorized'



$sql =  "SELECT carts.cart_id ,carts.fname, carts.lname, carts.country, carts.city, carts.street, carts.postnum,

          carts.epost, carts.comm, carts.delivery_name, carts.delivery_country, carts.admin_status,

          carts.delivery_city, carts.delivery_address, carts.delivery_postnum, carts.payment_method,

                                 carts.admin_status, cart_prods.cart_id, cart_prods.store_id, cart_prods.pname, cart_prods.pprice,

                                  cart_prods.amount, cart_prods.props

        FROM   carts

                               INNER JOIN cart_prods

                               ON carts.cart_id = cart_prods.cart_id

                                WHERE (status ='AUTHORIZED' AND admin_status = 5)

                               ORDER BY created

                               LIMIT 1";



                               $result = mysql_query($sql);

                              

                              

if (!$result) {

    echo "Could not successfully run query ($sql) from DB: " . mysql_error();

    exit;

}



if (mysql_num_rows($result) == 0) {

    echo "Ingen ordre igjen:-) Godt jobbet!!!";

    exit;

}

$row = mysql_fetch_assoc($result);{

$totalt = $row["pprice"] * $row["amount"];

    echo "<br>  Bestilte Produkter: <br> " ;

                echo "<br> Store Id: ";

                echo $row["store_id"];

                echo "<br> Cart Id: ";

                echo $row[cart_id]; // used in UPDATE query

                echo "<br> Navn: ";

                echo $row["pname"];

                echo "<br> Pris: ";

                echo $row["pprice"];

              //etc

}

?>



<input type=button onClick="parent.location='bekrefte.php'" value='Bekrefte ordre'>

<input type=button onClick="parent.location='sett_pa_vent.php'" value='Sett på vent'>

<input type=button onClick="parent.location='chartTest2.php'" value='Endring av kundedata'>



</body>

</html>



Bekrefte.php

<?php







$conn = mysql_connect("localhost", "root", "");



if (!$conn) {

    echo "Unable to connect to DB: " . mysql_error();

    exit;

}



if (!mysql_select_db("motecopy_mote")) {

    echo "Unable to select mydbname: " . mysql_error();

    exit;

}

header("location:chartTest2.php");

include ' chartTest2.php ';

mysql_query("UPDATE carts

            SET admin_status = 1

             WHERE cart_id = {$row[cart_id]}or die(mysql_error())");

                                                

                                                mysql_free_result($result);



?>

Link to comment
https://forums.phpfreaks.com/topic/200662-help-with-include/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.