Google Community Chat
 
Build an online dictionary by PHP/MySQL
Goto page 1, 2  Next
You're visiting Google Community as a guest.
In order to post, you'll need to register and log in.

(If you were registered and logged in, these advertisements wouldn't be here)
Post new topic   Reply to topic    Google Community Forum Index // Web Design, Coding & Programming Forum
   
Author Message
puccavn
Noogle
Noogle


Joined: 12 Apr 2005

1021.15 GC$

Items

PostPosted: Thu May 05, 2005 11:45 pm    Post subject: Build an online dictionary by PHP/MySQL Reply with quote
create a database with name: dict
and run these query

Code:
CREATE TABLE `words` (
 `id` tinyint(4) NOT NULL auto_increment,
 `eng` varchar(255) NOT NULL default '',
 `vie` varchar(255) NOT NULL default '',
 PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1;


Then create new file with name: dbconn.inc, copy codes below---> save

Code:
<?php     
    $link = mysql_connect ("localhost", "yourusernamehere", "yourpasshere")
    or die ("Could not connect to MySQL Database");
    mysql_select_db("dict", $link);
?>


Copy codes below to a text edition

Code:

<?php
echo("<a href=admin.php>ACP</a><br>");

if(isset($_GET['act']))
{
$do=$_GET['act'];
switch($do)
{
 case 'form': show_form();break;
 case 'sm' : submited();break;
 default : show_form; break;
}

}
else
{
show_form();
}

function show_form()
{
?>
<form name=frm method=POST action="index.php?act=sm">

Word : <input type=text name="word"> <input type=submit name="sbm" value="Submit">
</form>
<?

}
function submited()
{

require("dbconn.inc");
//if(isset($_POST['sbm']))
//{
 $word=$_POST['word'];
 
 $sql="select * from words where eng like '".$word."'";
 //echo($sql);
 $result=mysql_query($sql,$link);
 if(@mysql_num_rows($result)!=0)
 {
  while($rows=mysql_fetch_array($result))
  {
   $vie=$rows["vie"];
  }
  echo("Word<b>$word</b> in vietnamese is : <b>$vie</b><br>");
?>
<form name=frm method=POST action="index.php?act=sm">

Word : <input type=text name="word"> <input type="submit" name="sbm" value="Submit">
</form>
<?
 }
 else
  echo("Don't know that word !! My database is not update!");
//}
mysql_close($link);

}
?>


save with name: index.php

Copy this code to text editor:
Code:
<?php
echo("<a href=index.php>Home</a><br>");
if(isset($_GET['act']))
{
$do=$_GET['act'];
switch($do)
{
 case 'form': show_form(); break;
 case 'sm': submited(); break;
 default: show_form();
}

}
else
show_form();
function show_form()
{
?>
<form name=frm method=POST action=admin.php?act=sm>
English: <input type=text name="eng"><br>
Vietnam: <input type=text name="vie"><br>
<input type=submit name=sm value="Submit">
</form>
<?
}
function submited()
{
require("dbconn.inc");
if(isset($_POST['sm']))
{
 $eng=$_POST['eng'];
 $vie=$_POST['vie'];
 $sql="Insert into words(eng, vie) values('".$eng."','".$vie."')";
 $res=mysql_query($sql,$link);
 //header("Location: admin.php");
?>
<script language=Javascript>window.location="admin.php";</script>
<?

}
else
 echo("Insert data !!");
mysql_close($link);
}
?>



Save with name admin.php

upload these three files to your host
admin.php to insert more words into your db

base on these code you can make more dict, exp: fr-vie
comp...
and create more field forexp: adjective, noun, verb...

sorry for my bad english ( i'm from Vietnam )
Very Happy Very Happy
Back to top
View user's profile Send private message
bigmonkey
Junior Googler
Junior Googler


Joined: 21 Apr 2005

996.00 GC$

Items

PostPosted: Mon May 09, 2005 1:16 am    Post subject: Reply with quote
great job, i like your idea. I was gonna make a world dictionary for all languages Smile I will let u know when i start that project!

Maybe u can help
_________________
[Sig images removed, Please read the rules! -admin]
Back to top
View user's profile Send private message
puccavn
Noogle
Noogle


Joined: 12 Apr 2005

1021.15 GC$

Items

PostPosted: Sat Jun 18, 2005 2:56 am    Post subject: Reply with quote
okie !!
Try the best to help you !!
Back to top
View user's profile Send private message
frumau
Junior Googler
Junior Googler


Joined: 19 Jun 2005

2259.75 GC$

Items

PostPosted: Sun Jun 19, 2005 12:04 pm    Post subject: Reply with quote
I am new to php and have a question. I would like to make a dictionary the way you told but when you mention: "create a database with name: dict
and run these query".", do you mean that I should put that query file in the database file of my root directory?
_________________
Jasper
gateway2thailand
Back to top
View user's profile Send private message Send e-mail Visit poster's website
puccavn
Noogle
Noogle


Joined: 12 Apr 2005

1021.15 GC$

Items

PostPosted: Mon Jun 20, 2005 8:39 pm    Post subject: Reply with quote
run that query on phpmyadmin or write small PHP script to run it !!
This query will make an table in your database Laughing Crying or Very sad
Back to top
View user's profile Send private message
frumau
Junior Googler
Junior Googler


Joined: 19 Jun 2005

2259.75 GC$

Items

PostPosted: Thu Jun 23, 2005 8:13 am    Post subject: dictionary Reply with quote
Well I got phpmyadmin working and I entered your info. I adapted it cause I want a Dutch Thai Dictionary. But somehow the data I enter doesn't reach my table in the database. Here's your slightly altered script:

Admin.php:

<?php
echo("<a href=index.php>Home</a><br>");
if(isset($_GET['act']))
{
$do=$_GET['act'];
switch($do)
{
case 'form': show_form(); break;
case 'sm': submited(); break;
default: show_form();
}

}
else
show_form();
function show_form()
{
?>
<form name=frm method=POST action=admin.php?act=sm>
Nederlands: <input type=text name="nl"><br>
Thai: <input type=text name="th"><br>
<input type=submit name=sm value="Submit">
</form>
<?
}
function submited()
{
require("dbconn.inc");
if(isset($_POST['sm']))
{
$nl=$_POST['nl'];
$th=$_POST['th'];
$sql="Insert into words(nl, th) values('".$nl."','".$th."')";
$res=mysql_query($sql,$link);
//header("Location: admin.php");
?>
<script language=Javascript>window.location="admin.php";</script>
<?

}
else
echo("Insert data !!");
mysql_close($link);
}
?>

And index.php:

<?php
echo("<a href=admin.php>ACP</a><br>");

if(isset($_GET['act']))
{
$do=$_GET['act'];
switch($do)
{
case 'form': show_form();break;
case 'sm' : submited();break;
default : show_form; break;
}

}
else
{
show_form();
}

function show_form()
{
?><title>Woordenboek</title>
<form name=frm method=POST action="index.php?act=sm">

Word : <input type=text name="word"> <input type=submit name="sbm" value="Submit">
</form>
<?

}
function submited()
{

require("dbconn.inc");
//if(isset($_POST['sbm']))
//{
$word=$_POST['word'];

$sql="select * from words where eng like '".$word."'";
//echo($sql);
$result=mysql_query($sql,$link);
if(@mysql_num_rows($result)!=0)
{
while($rows=mysql_fetch_array($result))
{
$vie=$rows["vie"];
}
echo("Word<b>$word</b> in Thai is : <b>$vie</b><br>");
?>
<form name=frm method=POST action="index.php?act=sm">

Word : <input type=text name="word"> <input type="submit" name="sbm" value="Submit">
</form>
<?
}
else
echo("Don't know that word !! My database is not update!");
//}
mysql_close($link);

}
?>

Do you see any errors?

Thanx,

Jasper
_________________
Jasper
gateway2thailand
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pratik
Rusty
Googler


Joined: 12 May 2005

1320.80 GC$

Items

PostPosted: Thu Jun 30, 2005 5:24 pm    Post subject: Reply with quote
nice.. i tried it with my free hsot.. it worked then after few days later few host shut down .lol
Back to top
View user's profile Send private message
frumau
Junior Googler
Junior Googler


Joined: 19 Jun 2005

2259.75 GC$

Items

PostPosted: Thu Jun 30, 2005 11:53 pm    Post subject: Reply with quote
I fixed the problem. Had to change the char-set code for the connection to the Mysql server, for the index page and for the Mysql database and table to UTF-8 and now everything is working out very nicely. Thanks for the code!!
_________________
Jasper
gateway2thailand
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gilson_rosa
Noogle
Noogle


Joined: 03 Oct 2005

297.10 GC$

Items

PostPosted: Mon Oct 03, 2005 5:59 pm    Post subject: Chinese characters Reply with quote
Hy! Guys!!! I´m learning PHP and I´d like to create a Chinese-Portuguese dictionary, but how can I type Chinese characters? Portuguese has special signals and cannot be displayed properly. What should I do?
Back to top
View user's profile Send private message MSN Messenger
frumau
Junior Googler
Junior Googler


Joined: 19 Jun 2005

2259.75 GC$

Items

PostPosted: Mon Oct 03, 2005 11:12 pm    Post subject: Reply with quote
Use Unicode as char set for the transfer of the code, the database and the page you will have your dictionary on (encoding="utf-8" see Gateway2Thailand Dictionary ). I think unicode covers chinese characters as well. Portuguese for sure.

Cheers,
_________________
Jasper
gateway2thailand
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gilson_rosa
Noogle
Noogle


Joined: 03 Oct 2005

297.10 GC$

Items

PostPosted: Tue Oct 04, 2005 7:03 am    Post subject: DBTools Manager Professional Reply with quote
Thanks, Frumau for your quick reply.

I´m new in the PHP thing. If you don´t mind, could you please tell me where can I set this configuration on DBTools Manager Professional?

Thanks a lot!!!
Back to top
View user's profile Send private message MSN Messenger
frumau
Junior Googler
Junior Googler


Joined: 19 Jun 2005

2259.75 GC$

Items

PostPosted: Tue Oct 04, 2005 9:25 am    Post subject: Reply with quote
Well, I use phpmyadmin. A great free of charge Mysql organizer. There I have these charset settings:

MySQL charset: UTF-8 Unicode (utf8)
MySQL connection collation: utf8_general_ci

Try to find that in your programme.


Cheers,
_________________
Jasper
gateway2thailand
Back to top
View user's profile Send private message Send e-mail Visit poster's website
frumau
Junior Googler
Junior Googler


Joined: 19 Jun 2005

2259.75 GC$

Items

PostPosted: Tue Oct 04, 2005 9:28 am    Post subject: Reply with quote
P.S. Don't forget to make the encoding of the page which will contain de dictionary form utf-8!! With the dash(-). Otherwise people will have to change the character encoding themselves all the time to read the words.

Cheers,
_________________
Jasper
gateway2thailand
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gilson_rosa
Noogle
Noogle


Joined: 03 Oct 2005

297.10 GC$

Items

PostPosted: Tue Oct 04, 2005 9:45 am    Post subject: Reply with quote
Thanks again, Frumau! I already can type in Portuguese, but I still can´t type in Chinese. I don´t know what to do. Maybe I´ll have to use some other kind of codes.
Back to top
View user's profile Send private message MSN Messenger
frumau
Junior Googler
Junior Googler


Joined: 19 Jun 2005

2259.75 GC$

Items

PostPosted: Tue Oct 04, 2005 10:01 am    Post subject: Reply with quote
Did you change the table row's collation for the chinese and portuguese char set words to utf8_unicode_ci as well?

Or try big5_chinese_ci collation for the table rows containing the chinese characters although I think utf8 should work.. And if you do try it out you should maybe change the page encoding of the page displaying the chinese words as well to big5_chinese_ci.

Cheers,
_________________
Jasper
gateway2thailand
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sponsored Links
Posted: 9 Jan 2009 1:26 am    Post subject: Advertisements
Back to top
Post new topic   Reply to topic    Google Community Forum Index // Web Design, Coding & Programming Forum All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Host your free forums with Invision Plus.net forum web hosting with your own subdomain.

alexisBlue v1.2 // Theme Created By: Andrew Charron // Icons in Part By: Travis Carden

© 2005-2006 Google Community

Powered by phpBB

Privacy Policy | Contact Us

Powered by Google Search blog

This website is not affiliated in any way with Google, Inc.
Google™ is a registered trademark of Google, Inc.