• Web Development Questions That Don't Need Their Own Thread v2
    3,079 replies, posted
-snip, nevermind, misread the code I was trying to correct-
So what's the best way of storing translations of the same page in the database? I thought of several ways: 1) Store each language in its own table (products_en, products_lt, products_ru etc.) 2) Store each language in the same table, but instead of having one desc or title field have each for each language (may cause problems with scaling in the future if I want to add languages, I guess?) 3) Store each language in the same table, without multiple fields, however, fields like title and desc will actually be json arrays like this: [code] { { 'lt': 'blablabla' } { 'en': 'bladsads' } //etc.. } [/code] Or maybe there's even a better way you could think of?
[QUOTE=Crhem van der B;32843896]So what's the best way of storing translations of the same page in the database? I thought of several ways: 1) Store each language in its own table (products_en, products_lt, products_ru etc.) 2) Store each language in the same table, but instead of having one desc or title field have each for each language (may cause problems with scaling in the future if I want to add languages, I guess?) 3) Store each language in the same table, without multiple fields, however, fields like title and desc will actually be json arrays like this: [code] { { 'lt': 'blablabla' } { 'en': 'bladsads' } //etc.. } [/code] Or maybe there's even a better way you could think of?[/QUOTE] If you want to store them in a database, the best way is probably to implement a phrases system. Have a table for all the strings you want to translate, with a schema sort of like this: [code] id INT PRIMARY AUTO INCREMENT phraseid VARCHAR UNIQUE language VARCHAR (this can be an ISO 639 language code, or a constraint to another table of available languages, depends on the complexity of your application) phrase VARCHAR/TEXT [/code] [b]phrase[/b] is the translated string, [b]phraseId[/b] is a string representation of the translated string. For example, for the phrase: "Are you sure you'd like to poke your ex?", the phraseId can be something like "confirmPokeEx?". Then simply have an interface that loads the table for a chosen language (WHERE language=?), and provides methods for fetching a qualified(translated) string from a string identifier: Example code: (Localizer is a class I just made up) [code] $loc = new Localizer('en-us'); print $loc->get('confirmPokeEx?'); [/code] You can further extend and optimize this table by adding a [b]scope[/b] identifier (column), that is tied to specific portions of your application, so you don't have to load a whole language set into memory every time.
Thanks man, but I highly doubt the website I'm working on needs such a (relatively) complex system. I'll take into consideration to use your idea in my future projects when they'll be way more complex. I'll probably just use one of my three variants. Thanks again.
When allowing file uploads using PHP, is it better to grab the mime(?) type of the file, or just the extension. For restricting file types. If it's the mime(?) type, how would I go about doing that? Currently I just have an array of allowed file extensions, and the upload script grabs the extension of the uploaded file, and compares it to said array. Only problem with the way I'm doing it, is you can't have periods in the file name.
Has any one come across a good PHP file cache script? I've been using this one for a while: [url]http://devgrow.com/simple-cache-class/[/url] and it's worked wonders. But now that I've got weather information, Ads and other data that I don't want to be cached, I can't use it. You have to put the $cache->end(); tag after the </html> tag otherwise it gets the cached file contents and then exits. So if you have any information after the $cache->end(); it doesn't get outputted :(
making a website with a list of all my projects. this may be a bad idea, but i feel like just listing pall of them on 1 page. I could make multiple pages of my projects, but they are just so unrelated and it'd be difficult to categorize. Game, Software, "social networks", Webtools. I don't quite have enough in each to make a hefty page for 1 category. SO putting them all together would be ok, maybe? it's about 10 items total. So I was thinking of doing a grid (but that would limit the amount of information I could give on each project.) a single column would soak up a lot of space. oh... maybe a grid on the side (2 columns) and a theatre view with a large screen shot and more descriptive text. i think that will work? thoughts? [editline]19th October 2011[/editline] i have a <textarea> and then <input checkbox's> under it. They inputs are showing up right next to it though. How do i use css on the <textarea> to make the checkboxes go under
[QUOTE=Sprite;32864657]making a website with a list of all my projects. this may be a bad idea, but i feel like just listing pall of them on 1 page. I could make multiple pages of my projects, but they are just so unrelated and it'd be difficult to categorize. Game, Software, "social networks", Webtools. I don't quite have enough in each to make a hefty page for 1 category. SO putting them all together would be ok, maybe? it's about 10 items total. So I was thinking of doing a grid (but that would limit the amount of information I could give on each project.) a single column would soak up a lot of space. oh... maybe a grid on the side (2 columns) and a theatre view with a large screen shot and more descriptive text. i think that will work? thoughts? [editline]19th October 2011[/editline] i have a <textarea> and then <input checkbox's> under it. They inputs are showing up right next to it though. How do i use css on the <textarea> to make the checkboxes go under[/QUOTE] <textarea></textarea><br />
html way [QUOTE=mobrockers2;32867834]<textarea></textarea><br />[/QUOTE] css way margin-bottom:10px;
[QUOTE=Known Havok;32869318]html way css way margin-bottom:10px;[/QUOTE] How does that make the checkboxes go under the textarea? The checkboxes are right next to the textarea, a margin-bottom shouldn't fix that?
[QUOTE=mobrockers2;32872540]How does that make the checkboxes go under the textarea? The checkboxes are right next to the textarea, a margin-bottom shouldn't fix that?[/QUOTE] Set them to "display:block;" /e CSS animation [url]https://github.com/daneden/animate.css[/url]
What's the best IDE for web dev?
phped (if you're using php)
[QUOTE=Shooter;32876571]What's the best IDE for web dev?[/QUOTE] personal preference
What are good beginner/intermediate PHP projects?
Sublime Text vs Notepad++? I love/use Notepad++ way more then Sublime Text.
[QUOTE=hacksore;32880717]Sublime Text vs Notepad++? I love/use Notepad++ way more then Sublime Text.[/QUOTE]and you also think vbulletin is better than xenforo, so clearly you have some logic issues
[QUOTE=hacksore;32880717]Sublime Text vs Notepad++? I love/use Notepad++ way more then Sublime Text.[/QUOTE] sublime text i can use it on linux natively!
[code] 33.$result = mysql_query("SELECT * FROM inputtext"); 34. $row = mysql_fetch_array($result); 35. while ($row){ 36. echo $row[inputtext]; 37. } [/code] I am new to MySQL, and I am getting this error when I attempt to get all the rows in my database. I have no idea why it isn't working, can someone lend me a hand? Error: [img]http://puu.sh/7jcx[/img]
[QUOTE=toaster468;32881120][code] 33.$result = mysql_query("SELECT * FROM inputtext"); 34. $row = mysql_fetch_array($result); 35. while ($row){ 36. echo $row[inputtext]; 37. } [/code] I am new to MySQL, and I am getting this error when I attempt to get all the rows in my database. I have no idea why it isn't working, can someone lend me a hand? Error: [img]http://puu.sh/7jcx[/img][/QUOTE] the query seems to have failed or you did something wrong (don't you need like the mysql_connect or something?), and it's returning false.
[code] <body> <?PHP mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("guestbook") or die(mysql_error()); $row = mysql_fetch_array(mysql_query("SELECT * FROM input")); ?> <div id="message"><?PHP $result = mysql_query("SELECT * FROM inputtext"); $row = mysql_fetch_array($result); $rowbool = (bool)$row; while ($rowbool){ echo $row[inputtext]; } ?></div> <form action="postreply.php" method="post"> <input type="textbox" name="text" /> <input type="submit" value="Submit" /> </form> </body> </html> [/code] Yeah I already connected, everything works up until the while loop.
[QUOTE=toaster468;32881193][code] <body> <?PHP mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("guestbook") or die(mysql_error()); $row = mysql_fetch_array(mysql_query("SELECT * FROM input")); ?> <div id="message"><?PHP $result = mysql_query("SELECT * FROM inputtext"); $row = mysql_fetch_array($result); $rowbool = (bool)$row; while ($rowbool){ echo $row[inputtext]; } ?></div> <form action="postreply.php" method="post"> <input type="textbox" name="text" /> <input type="submit" value="Submit" /> </form> </body> </html> [/code] Yeah I already connected, everything works up until the while loop.[/QUOTE] then it seems your query is messed up
[QUOTE=Ac!dL3ak;32881272]then it seems your query is messed up[/QUOTE] How do I do it correctly then? Got it, thanks.
[QUOTE=TehWhale;32880757]and you also think vbulletin is better than xenforo, so clearly you have some logic issues[/QUOTE] Fuck off TehWhale, it's my own opinion isn't it!
[QUOTE=hacksore;32881615]Fuck off TehWhale, it's my own opinion isn't it![/QUOTE] also, vB>XenFouro
[QUOTE=hacksore;32880717]Sublime Text vs Notepad++? I love/use Notepad++ way more then Sublime Text.[/QUOTE] Sublime 2 is prettier and I find it easier to use. It also runs native on Linux :D [editline]20th October 2011[/editline] [QUOTE=TehFhale;32881638]also, vB>XenFouro[/QUOTE] let's not start a forum software fight..
[PHP]<html> <head> <title>Antivirus Program</title> </head> <body> <h2>Checking for Viruses</h2> <p> A computer can be checked for viruses using an antivirus program. An antivirus program is a utility that scans a hard disk for viruses. If a virus is located, it will be removed by the antivirus program.</p> <h2>Example Virus Threats</h2> <table border="2" width="300" cellpadding="5"> <th>Virus</th> <th>Threat</th> <tr><td>BackDoor-AWQ.e</td> <td>Low</td></tr> <tr><td>MultiDropper-RV</td> <td>Low</td></tr> <tr><td>Spy-Agent.cm</td> <td>Medium</td></tr> </table> </body> </html> [/PHP] Is it possible to add shading into the table?
[code]Column count doesn't match value count at row 1[/code] What the fuck does that mean? [code]mysql_query("INSERT INTO input (inputtext) VALUES(inputtext,$string) ") or die(mysql_error()); [/code]
You have one column specified and trying to put in two values.
[QUOTE=TehWhale;32881767]You have one column specified and trying to put in two values.[/QUOTE] But if I take out inputtext, it shits itself, but If I leave it and take out $string it is fine, and it creates a row without any text. EDIT: I love PhpMyAdmin!
Sorry, you need to Log In to post a reply to this thread.