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

  • Home
  • SEARCH
  • 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 8455547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:18:48+00:00 2026-06-10T12:18:48+00:00

help needed. When a column value of the column customer_id=’0′, I need to replace

  • 0

help needed. When a column value of the column customer_id=’0′, I need to replace it with the value ‘Guest’. Here is my code, I have tried everything I could find without success. Thanks in advance.

<?php
//Connection to database
mysql_connect("localhost","Username","Password");
mysql_select_db("DB_Name");

$result = mysql_query("SELECT

`order`. order_id,
`order`. customer_id,
`order`. payment_company,
`order`. payment_address_1,
`order`. payment_address_2,
`order`. payment_city,
`order`. payment_zone,
`order`. payment_postcode,
`order`. payment_firstname,
`order`. payment_lastname,
`order`. telephone,
`order`. email

FROM `order`
INNER JOIN customer ON `order`.customer_id = customer.customer_id
WHERE order_status_id > 0 ORDER BY order_id");
if (!$result) die('Sorry, I was unable to any fetch records. Try again');
$num_fields = mysql_num_fields($result);

$headers = array();

// Creating headers for output files
for ($i = 0; $i < $num_fields; $i++)
{
    $headers[] = mysql_field_name($result , $i);
}

$fp = fopen('php://output', 'w');
if ($fp && $result)
{
// name of file with date
    $filename = "Filename-".date('Y-m-d').".csv";

        // Setting header types for csv file.
        header('Content-Type: text/csv');
        header('Content-Disposition: attachment; filename='.$filename);
        header('Pragma: no-cache');
        header('Expires: 0');
        fputcsv($fp, $headers);

        while ($row = mysql_fetch_row($result))
        {
             fputcsv($fp, array_values($row));
        }
        die;
 }
?>
  • 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-06-10T12:18:49+00:00Added an answer on June 10, 2026 at 12:18 pm
    SELECT order.order_id,
           CASE WHEN order.customer_id = '0' THEN 'Guest' ELSE order.customer_id END AS customer_id, 
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help to convert value of the column Pct_To_Total into John, 0,36 Sophia, 0,29
Help needed.. I have a organization layout which have rectangular shapes not in an
Help needed! I have 10 different .png files and i want to display them
Some MATLAB help needed ! I have an set of 1s and 0s, I
I have a CSV file with many rows in which I need to update/replace
Immediate help needed!! The code used to work fine, but after a while I
I need some help again. I have a GridView with CheckBox es in first
I have a dataset. I added a column Tags. I need to run a
Help needed. Im writing a function that returns result of ajax call but i
Beginner help needed :) I am doign an example form a php book which

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.