Good day people,

i have a question that's been annoying me for a while now.. and i could not find an answer to it.

here it goes... let's say i have a table [language] in my database [lang]

it has four columns [languageid][phraseid][title][text]

so for example.. the values would be like so

// ##### languageid ###### phraseid ######## title ######### text
// ##### ____1____ ####### ___1___ ####### username ####### Username
// ##### ____1____ ####### ___2___ ####### password ####### Password

NOTE: phraseid is "auto_increment" and obviously a "Primary".

you've probably guessed what i want to do with it... for those who didn't,,, i want to use the [text] field in the [language] table to print phrases in an HTML page to use them as phrases...

for example:

<table>
  <tr>
    <td>$language[username]</td>
    <td><input type="text" name="name"></td>
    <td>$language[password]</td>
    <td><input type="password" name="pass"></td>
  </tr>
</table>

that should come out like...

          ____________________
Username |____________________|
          _____________________
Password |____________________|

what code should i use,, how to call a certain field in a certain table..

i was thinking like $language[text][1] with mysql_fetch_rows or something like that.. i could not find a way...

so.... please help :rolleyes:

i would really appreciate it.

    i was thinking like $language[text][1] with mysql_fetch_rows or something like that.. i could not find a way...

    What is this database and table for, and how proficient are you at PHP and SQL?

      laserlight wrote:

      What is this database and table for, and how proficient are you at PHP and SQL?

      the database is just a database where i have the tables[users],[style],[language].. and so on..

      the table [language] is to add languages English... French... Chinese.. and so on..

      [English] -> [languageid=1]
      [French] -> [languageid=2] ... etc

      i'm not that good in PHP and MYSQL... but i do fine i guess 🙂

        the table [language] is to add languages English... French... Chinese.. and so on..

        Ah, so basically you want to translate certain words and phrases based on the user's options.

        i'm not that good in PHP and MYSQL... but i do fine i guess

        Just hcecking, because running a loop to retrieve rows from a result set is one of the basic things you need to know. An example would be:

        while ($row = mysql_fetch_assoc($result)) {
            echo $row['text'];
        }
          laserlight wrote:

          An example would be:

          while ($row = mysql_fetch_assoc($result)) {
              echo $row['text'];
          }

          yeah that's easy,,, anyways,,, thanks for your replay... i got my answer

          well... i knew i should use some sort of an array for the phrases,,, but i didn't know how!

          then i got it from someone...

          <?php
            $lid = 1; //Language ID figured out somewhere else
          
            //Run this before every script
            $sql = 'SELECT title, text FROM language WHERE languageid = "{$lid}"';
            $query = mysql_query($sql);
            $phrases = array();
            while($row = mysql_fetch_assoc($query))
              $phrases[$row['title']] = $row['text'];
          
            //In your script
            echo $phrases['username'];
          ?>
          

          thank you all for the help 🙂

            Write a Reply...