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

The Archive Base Latest Questions

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

I’m developing a parents evening booking system as part of my A level programming

  • 0

I’m developing a parents evening booking system as part of my A level programming project, but I’ve just gotten stuck.
I’ll try explain the project the best I can in this post, so I can give you guys a clear picture of what the application does.

So far:
I have created a sort of language selector function with php, which gets the users language selection before logging in based upon a cookie. Here’s the code for the script (Yes, very messy right now, but i’ll fix it later on):

function check_language() { 

//directory name for the custom defined languages.
$dir = 'languages'; 

//set a default language
$default = 'english';

//make sure that we have a language selected...
if (!isset($_COOKIE["lang"])){ 
    //if there is no cookie set, set one.
    setcookie("lang", "english", time()+3600*24*365);
}else{ 
    $lang = ($_COOKIE["lang"]); 
} 

//build the path string.
$path = $dir."/".$lang.".php";


if (file_exists($path)) {
    //return the selected language pack directory.
    return $path;
}else{
    //protect the server, by returning the default language path...
    return $dir."/".$default.".php";
}

} 

Whenever I want my PHP script to access language files, I call the function I have created and then include the language file on the page like so:

$lang = check_language();
include_once($lang); 

english.php file…

$txt['languagename'] = "English";

//text for the index page...
$txt['titletext'] = 'Parents evening booking system'; 
$txt['welcometext1'] = 'Welcome to the parents evening booking system for '; 

welsh.php file…

$txt['languagename'] = "Cymraeg";

//text am y tudalen index...
$txt['titletext'] = 'System bwcio noson rhieni'; 
$txt['welcometext1'] = 'Croeso i system bwcio noson rhieni '; 

So for example, if the users cookie contains ‘welsh’, the file welsh.php would be included, and I would have access to an associative array ($txt), with the supplied translations.
That part of my script works perfectly so far.

Now i’m coding the admin page, and I need an option to be able to add a school year to the database through the admin panel.
This is where i’m a bit confused on what to do, as the string (‘year 10’ for example) would be ‘blwyddyn 10’ in welsh. So this means I would need to add another element to the associate array for all language files with a string for the required language so it could be accessed in the script. (if this makes any sense at all).

I have created a table in the database for all languages like so:

languageid     name         filename
1              English  english.php
2              Welsh    welsh.php

Then I wrote this code to connect to the database and create an input box for each language in the database, along with a “translation id key” input box.

include'/inc/functions.php');
ConnectToDB();

$query = "SELECT * FROM languages WHERE 1";
$result = mysql_query($query);

$languages = array();

while($row = mysql_fetch_assoc($result)){
    $languages[] = $row['name'];
}

    echo 'Translation key id: <input type="text" name="languagetermkey"/>';
    echo '</br>';

    foreach($languages as $item){
        echo 'Year name ('.$item. " string):";
        echo '<input type="text" name="'.$item.'String'.'"/>'; //e.g "EnglishString"
        echo "</br>";
    }

Now if I wanted to add the terms above (the text from both input boxes) into my language files (“english.php” and “welsh.php”) how would I go about sending an array with an ajax post request?

Previously I have been using this code, but I guess it won’t work for what I want to do this time 🙁

$.ajax({
  type: 'post',
  url: 'add_class.php',
  data: 'classname=' + "test",
  error: function(){
        alert('There was a problem adding the class !');
    },
  success: function() {
        alert("Class has been added successfuly");
    }
});

Is this the right way to go about doing this sort of thing ? If not, can somebody guide me towards the right direction on what to do? i’m just a bit confused and this is my first time using jQuery.

I know this post is long, and I do appreciate people’s efforts for reading the whole thing.

Thanks in advance for any replies (Y)

  • 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:00:07+00:00Added an answer on May 25, 2026 at 2:00 pm

    For the bit about sending the array with AJAX, you can serialize a form and pass that, meaning you can access it just as if it was a normal POST from PHP.

    $.ajax({
      type: 'post',
      url: 'add_class.php',
      data: $('#formID').serialize(),
      error: function(){
            alert('There was a problem adding the class !');
        },
      success: function() {
            alert("Class has been added successfuly");
        }
    });
    

    For the “Year 10”, you can use sprintf or vsprintf like this – example showing both sprintf and vsprintf.

    $year = 'Year %d';
    $yearWelsh = 'Blwyddyn %d';
    
    echo sprintf($year, 10) . ', or in Welsh, we say ' . vsprintf($yearWelsh, array(10));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I want to construct a data frame in an Rcpp function, but when I
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.