Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:42:42+00:00 2026-05-25T14:42:42+00:00

I have got a script under this link Order list/ while loop php issue

  • 0

I have got a script under this link Order list/ while loop php issue which retrieves an order row of data from the following fields:

order_id | users_id | total | order_date(CURRENT_TIMESTAMP) | shipped

I have since added a radio button in which the admin user can click to show if this item has been shipped. (It adds a ‘YES’ or ‘NO’ to the shipped field through a submit button) The SQL query is below:

UPDATE orders SET shipped='$shipped' WHERE order_id='$id'

The script works fine but it replaces the time that the order was originally made (under ‘order_date’) with the time that the shipping button has been submitted and I want to leave the original time intact.

Can I change the SQL query or do I have to use php to this? Please let me know if you need to see the full php code.

<?php # edit_user.php

$page_title = 'View Individual Order';
include ('includes/header_admin_user.html');

// If no dealer_code variable exists, redirect the user.
if (!isset($_SESSION['admin_int_id'])) {

   // Start defining the URL.
   $url = 'http://' . $_SERVER['HTTP_HOST']
    . dirname($_SERVER['PHP_SELF']);
   // Check for a trailing slash.
   if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
        $url = substr ($url, 0, -1); // Chop off the slash.
   }
   // Add the page.
   $url .= '/login.php'; 

ob_end_clean(); // Delete the buffer.
header("Location: $url"); 
exit(); // Quit the script.
}

// Check for a valid user ID, through GET or POST.
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) )
   { // Accessed through view_users.php   
    $id = $_GET['id'];

} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) )
   { // Form has been submitted.   
    $id = $_POST['id'];
} else { // No valid ID, kill the script.
    echo '<h1 id="mainhead">Page Error</h1>
    <p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
    include ('./includes/header.html'); 
    exit();
}

?>

<h1>Order Details</h1>

<?php

require_once ('mydatabase.php'); // Connect to the db.

$shipped = $_POST["shipped"];

if (isset($_POST['submitted'])) {

          // Make the query.
          $query = "UPDATE orders SET shipped='$shipped' WHERE order_id=$id";   
          $result = @mysql_query ($query); // Run the query.
          if (mysql_affected_rows() == 1) { // If it ran OK.

          // Print a message.
          echo '<p style="color:#5a8e22;"><strong>The order has been sent.</strong></p>
          <br />';

          } else { // If it did not run OK.
            echo '<p style="color:#be0f34; font-size:120%;"><strong>Error</strong></p>
            <p style="color:#be0f34;">This update request could not be made for one of the following reasons:<br>
            <br>
            <a href="view-all-orders-test.php"><< Go back to order list</a>';   
           echo '<p>' . mysql_error() . '<br /><br />
            Query: ' . $query . '</p>
            </p>
            <br class="clearboth" />
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            </div>
            </div>'
            ; // Debugging message.   
          include ('./includes/footer_admin_user.html'); 
          exit();
          ; // Public message.

          }

} // End of submit conditional.


// Retrieve the user's, order and product information.
$query = "SELECT us.users_id, us.users_sales_guild_id, us.users_first_name, us.users_surname, us.users_dealer_name, us.users_type, 
         us.users_address_street, us.users_address_suburb, us.users_address_state, us.users_address_postcode, 
         us.users_address_phone, us.registration_date, 
         ord.order_id, ord.users_id, ord.total, ord.order_date,  
         oc.oc_id, oc.order_id, oc.products_id, oc.quantity, oc.price,
         prd.products_id, prd.products_name, prd.price      
         FROM users AS us, orders AS ord, order_contents AS oc, products AS prd  
         WHERE ord.order_id=$id
         AND us.users_id = ord.users_id
         AND ord.order_id = oc.order_id
         AND oc.products_id = prd.products_id    
         ";

$result = mysql_query ($query) or die(mysql_error());

if (mysql_num_rows($result)) { // Valid user ID, show the form.

    $row = mysql_fetch_array($result, MYSQL_NUM);

   echo '<table width="400" border="0" cellspacing="0" cellpadding="0">
        <tr valign="top">
        <td width="65%"><p><strong>Deliver to:</strong><br />
        ' . $row[2] . ' ' . $row[3] . ' <br />
        ' . $row[5] . ', ' . $row[1] . ' <br />
        </p>

        <p><strong>Dealership:</strong><br />
        ' . $row[4] . ' <br />
        ' . $row[6] . ' <br />
        ' . $row[7] . ', ' . $row[8] . ', ' . $row[9] . ' <br />
        </p>

        </td>
        <td width="35%">
        <p><strong>Order Total:</strong><br />
        ' . $row[14] . ' pts <br />
        </p>
        <p><strong>Date:</strong><br />
        ' . $row[11] . ' <br />
        </p>
        </td>
        </tr>
        </table>

        <form method="post" action="view-ind-order-test.php">
        Has this order been shipped?<br />
        Yes:<input type="radio" value="YES" name="shipped">  No:<input type="radio" value="NO" name="shipped"><br />
        <input type="submit" name="submit" value="Submit" />
        <input type="hidden" name="submitted" value="TRUE" />
        <input type="hidden" name="id" value="' . $id . '" />
        </form><br />

        <p></p> 

        <table border="0" width="400" cellspacing="1" cellpadding="5">
        <tr class="top">
        <td align="left" ><b>Product</b></td>
        <td align="center"><b>Qty</b></td>
        <td align="center"><b>Price</b></td>

        </tr>';

    $bg = '#dddddd'; // Set the background color.

    do { // DO WHILE loop start

    $bg = ($bg=='#eaeced' ? '#dddddd' : '#eaeced');

    echo    '<tr bgcolor="' . $bg . '">';

    echo    '<td align="left">' . $row[22] . '</td>
            <td align="center">' . $row[19] . '</td>
            <td align="center">' . $row[20] . '</td>
            </tr>';

            } while($row = mysql_fetch_array($result, MYSQL_NUM));// end of WHILE loop

        echo '</table>
            <br><br>
            <p><a href="view-all-orders-test.php"> << Back to Orders</a></p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            ';

} else { // Not a valid user ID.
    echo '<h1 id="mainhead">Page Error</h1>
    <p class="error">This page has been accessed in error.</p><p><br /><br /></p>';   
}

mysql_close(); // Close the database connection.


?>

<p>footer</p>

<?php
include ('./includes/footer_admin_user.html'); // Include the HTML footer.
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:42:43+00:00Added an answer on May 25, 2026 at 2:42 pm

    @gview is right that you should alter your table and make it DEFAULT CURRENT_TIMESTAMP. If you cannot alter the table, you can change your update query to set order_date = order_date, which will prevent it from being updated:

    UPDATE orders SET shipped='$shipped', order_date = order_date WHERE order_id='$id'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a python script which is creating an ODBC connection. The ODBC
We have got loads of options for php + MySQL + Apache combo... Which
I've got a little problem on a goDaddy server. I have a php script
I have got this script that works fine, that allows a user to vote,
I'm receiving files (images) uploaded with Ajax into my PHP script and have got
I have a Jquery Script which is depenedent on this Script Sort.js . Can
I've got a file whose format I'm altering via a python script. I have
I have got some code to load an assembly and get all types, which
I have got this error when using Enterprise Library 3.1 May 2007 version. We
I have this piece of script : #!/usr/bin/perl use strict; use warnings; use Data::Dumper;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.