Google Community
Latest Forums Rules Resources
Custom Search

Go Back   Google Community > Webmaster Forums > Web Design, Coding & Programming Forum

GoogleCommunity Sponsor
Cirtex Hosting
Use coupon "forum" for 50% Off!

Reply
 
LinkBack Thread Tools Display Modes
Old 05-06-2005, 12:45 AM   #1 (permalink)
Noogle
 
Join Date: Apr 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
puccavn
Build an online dictionary by PHP/MySQL

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>
");

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$word in vietnamese is : $vie
");
?>
<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>
");
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">

Vietnam: <input type=text name="vie">

<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 )
puccavn is offline   Reply With Quote
 
Sponsored Links
Old 05-09-2005, 02:16 AM   #2 (permalink)
Junior Googler
 
Join Date: Apr 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
bigmonkey
great job, i like your idea. I was gonna make a world dictionary for all languages I will let u know when i start that project!

Maybe u can help
bigmonkey is offline   Reply With Quote
Old 06-18-2005, 03:56 AM   #3 (permalink)
Noogle
 
Join Date: Apr 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
puccavn
okie !!
Try the best to help you !!
puccavn is offline   Reply With Quote
Old 06-19-2005, 01:04 PM   #4 (permalink)
Junior Googler
 
Join Date: Jun 2005
Posts: 45
Thanks: 0
Thanked 1 Time in 1 Post
frumau
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?
frumau is offline   Reply With Quote
Old 06-20-2005, 09:39 PM   #5 (permalink)
Noogle
 
Join Date: Apr 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
puccavn
run that query on phpmyadmin or write small PHP script to run it !!
This query will make an table in your database
puccavn is offline   Reply With Quote
Old 06-23-2005, 09:13 AM   #6 (permalink)
Junior Googler
 
Join Date: Jun 2005
Posts: 45
Thanks: 0
Thanked 1 Time in 1 Post
frumau
dictionary

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>
");
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">

Thai: <input type=text name="th">

<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>
");

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$word in Thai is : $vie
");
?>
<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
frumau is offline   Reply With Quote
Old 06-30-2005, 06:24 PM   #7 (permalink)
Googler
 
Join Date: May 2005
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
pratik
nice.. i tried it with my free hsot.. it worked then after few days later few host shut down .lol
pratik is offline   Reply With Quote
Old 07-01-2005, 12:53 AM   #8 (permalink)
Junior Googler
 
Join Date: Jun 2005
Posts: 45
Thanks: 0
Thanked 1 Time in 1 Post
frumau
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!!
frumau is offline   Reply With Quote
Old 10-03-2005, 06:59 PM   #9 (permalink)
Noogle
 
Join Date: Oct 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
gilson_rosa
Send a message via MSN to gilson_rosa
Chinese characters

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?
gilson_rosa is offline   Reply With Quote
Old 10-04-2005, 12:12 AM   #10 (permalink)
Junior Googler
 
Join Date: Jun 2005
Posts: 45
Thanks: 0
Thanked 1 Time in 1 Post
frumau
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,
frumau is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the longest word in the dictionary? kcmandava Chit Chat 18 12-02-2008 07:19 PM
Chav makes the dictionary dude66 Chit Chat 6 06-16-2005 09:22 AM
Google no longer using dictionary.com; now answers.com intelliot All About Google 11 01-30-2005 11:47 AM
Googler in dictionary malapati All About Google 5 11-07-2004 07:51 PM
What is the longest word in the dictionary? kcmandava Chit Chat 17 01-01-1970 07:00 PM


All times are GMT -8. The time now is 02:05 AM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© 2004–2007 Google Community