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 7737635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:03:11+00:00 2026-06-01T08:03:11+00:00

OK folks, here’s a fun one for you. So our back office system has

  • 0

OK folks, here’s a fun one for you.

So our back office system has all the cruise fares in it and we’ve made a nice little script that allows the back office system’s export of the fares to import into the website.

It’s a neat script, except… the back office system exports the cruise code e.g. P210 and the website’s database has a fares table which contains each fare as record, connected to the relevant cruise by a ‘cruise_id’

So the cruise table is something like this

id title code departs….. etc etc

and the fare table is like this

id cruise_id fare offer… etc etc

Works great on the site, but the back office export doesn’t know the unique id of the cruise on the website.

So is it possible, after we have uploaded the csv file, before it inserts, to look up the cruise_id from the cruises table using the code, and use that in the insert query ?

Here’s the upload script so far

<?php
 require_once('includes/connection.php');
 if(isset($_POST['submit']))
   {
     $filename=$_FILES['filename']['tmp_name'];
     $handle = fopen("$filename", "r");
     while (($data = fgetcsv($handle, 100000, ",")) !== FALSE)
     {

       $import="INSERT into fares_usa(cruise_id, active, type, category, placement, deck, fare, offered, status, sortorder) 
       values('".mysql_real_escape_string($data[0])."',
       '".mysql_real_escape_string($data[1])."',
       '".mysql_real_escape_string($data[2])."',
       '".mysql_real_escape_string($data[3])."',
       '".mysql_real_escape_string($data[4])."',
       '".mysql_real_escape_string($data[5])."',
       '".mysql_real_escape_string($data[6])."',
       '".mysql_real_escape_string($data[7])."',
       '".mysql_real_escape_string($data[8])."',
       '".mysql_real_escape_string($data[9])."')";
       mysql_query($import, $connection) or die(mysql_error());
     }
     fclose($handle);
     print "Import done";
   }
   else
   {

      print "<form enctype='multipart/form-data' action='fileupload.php' method='POST'>";
      print "Select file to import:";
      print "<input type='file' name='filename' size='20'>";
      print "<input type='submit' name='submit' value='submit'></form>";
   }
   ?>

I hope I have explained it ok…

Rich 🙂

  • 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-01T08:03:12+00:00Added an answer on June 1, 2026 at 8:03 am

    fixed it… here’s the code

    <?php
     require_once('includes/connection.php');
     if(isset($_POST['submit']))
       {
         $filename=$_FILES['filename']['tmp_name'];
         $handle = fopen("$filename", "r");
         while (($data = fgetcsv($handle, 100000, ",")) !== FALSE)
         {
             $lookup_cruise = mysql_real_escape_string($data[0]);
    
        $query_cruiseid = "SELECT id FROM cruises WHERE code = '{$lookup_cruise}'";
        $get_cruiseid = mysql_query($query_cruiseid, $connection);
            $cruise_id = mysql_fetch_assoc($get_cruiseid);
    
    
           $import="INSERT into fares_usa(cruise_id, active, type, category, placement, deck, fare, offered, status, sortorder) 
       values('".mysql_real_escape_string($cruise_id['id'])."',
       '".mysql_real_escape_string($data[1])."',
       '".mysql_real_escape_string($data[2])."',
       '".mysql_real_escape_string($data[3])."',
       '".mysql_real_escape_string($data[4])."',
       '".mysql_real_escape_string($data[5])."',
       '".mysql_real_escape_string($data[6])."',
       '".mysql_real_escape_string($data[7])."',
       '".mysql_real_escape_string($data[8])."',
       '".mysql_real_escape_string($data[9])."')";
       mysql_query($import, $connection) or die(mysql_error());
         }
         fclose($handle);
         print "Import done";
       }
       else
       {
    
      print "<form enctype='multipart/form-data' action='fileupload.php' method='POST'>";
      print "Select file to import:";
      print "<input type='file' name='filename' size='20'>";
      print "<input type='submit' name='submit' value='submit'></form>";
       }
      ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any help at all is appreciated here folks. I'm building a web app in
Folks, here's a thorny problem for you! A part of the TickZoom system must
Folks, I know this question has been asked before here, though indirectly . But
Folks, Matlab 2007b (7.5.0) has an avgpower function. See here : The avgpower method
What do folks here see as the relative strengths and weaknesses of Git, Mercurial,
I tend to get the feeling that most folks here think SVN is gold-plated
What am I doing wrong here folks? <?php include 'header.php'; /** * Display a
I'm being completely confused here folks, My code throws an exception because File.Exists() returns
Folks, we all know that IP blacklisting doesn't work - spammers can come in
I've noticed that a lot of folks here cite tables with 20+ (I've seen

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.