Jump to content

Search the Community

Showing results for tags 'singletable'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hello, I have used Single Translation Table Approach to make multilanguage site in PHP. You may see here The current index page is not working. My objective is to have one example to use these tables and display one working page. For example: It should work like this by using those tables (app_language, app_product, app_translation, app_translation_entry). What i did so far on my home page: <!DOCTYPE html> <?php session_start(); $_SESSION['current_language'] = "fr"; $con = mysql_connect("localhost","worksite",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("worksite", $con); ?> <?php // handle language selection if(in_array($_GET['lang'], $languages)) { $_SESSION['lang'] = $_GET['lang']; } // define LANG constant only if it exists in $languages array, otherwise default to EN define('LANG', in_array($_SESSION['lang'], $languages) ? $_SESSION['lang'] : 'fr'); define('LANG', in_array($_SESSION['lang'], $languages) ? $_SESSION['lang'] : 'en'); // display language options foreach($languages as $language) { echo '<a href="?lang='.$language.'">'.$language.'</a>'; } $sql = "SELECT p.*, l.name as language_name, te.field_text as title FROM `app_product` p INNER JOIN `app_translation_entry` te ON p.title = te.translation_id INNER JOIN `app_language` l ON te.language_code = l.code WHERE p.id = 1"; if($result = mysql_query($sql)){ while($row = mysql_fetch_assoc($result)){ echo "Language (".$row["language_name"]."): ".$row["title"]."<br>"; } } // Retrieve appropriate title according to the chosen language in the system $sql = "SELECT p.*, l.name as language_name, te.field_text as title FROM `app_product` p INNER JOIN `app_translation_entry` te ON p.title = te.translation_id INNER JOIN `app_language` l ON te.language_code = l.code WHERE p.id = 1 AND te.language_code = '".$_SESSION['current_language']."'"; if($result = mysql_query($sql)){ if($row = mysql_fetch_assoc($result)){ echo "Current Language: ".$row["title"]; } } ?> </body> </html> You may edit this file as you wish but it should be working as per example link (demo). I want to build static website from above approach. Thanks in advanced for your time and input.
×
×
  • 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.