<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Data entry' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Data entry' posted on the 'PHP' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 05:19:52 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 05:19:52 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Data entry</title>
      <link>http://www.programmersheaven.com/mb/phpstuff/428735/428735/data-entry/</link>
      <description>Hello guys!&lt;br /&gt;
I'm making a multi-lingual dictionary. I have a problem with the data entry. I want to check if the word already exists in dictionaries database. if yes, notify me, else, insert it. Also the English table should contain this word. for example, the word feu = fire in french, if I added it, my script should check if 'fire' exists in english dictionary, if not add it.&lt;br /&gt;
I get funny results. I know it's due to a mistake in my code. I need your help.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;&amp;lt;?php
/*
1- check if data exists in $Dictionary table, if yes, notify me, else, insert and show confirmation.
2- check if $translation exists in English dictionary, if yes, notify me, else, insert it as a new english word.
*/

//inputs
$dictionary = $_POST['language'];
$word = $_POST['word'];
$translation = $_POST['translation'];
$wordtype = $_POST['wordtype'];
$extra = $_POST['extra'];

$con= mysql_connect("localhost","root","")or die('couldn\'t connect to mysql'. mysql_error());
mysql_select_db("dictionaries",$con);

$check  = mysql_query("SELECT COUNT(*) FROM $dictionary WHERE Word = '$word'",$con);
$checkEnglish = mysql_query("SELECT COUNT(Word) FROM English WHERE Word = '$translation'",$con);
$updateEnglish = mysql_query("INSERT INTO English(Word,Translation,Wordtype)Values('$transla
tion','$translation','$wordtype')",$con);
$query =mysql_query("INSERT INTO ".$dictionary." (Word,Translation,Wordtype,extra) values('$word','$translation','$wordtype','$extra'
)",$con);

print"
&amp;lt;HTML&amp;gt;
&amp;lt;HEAD&amp;gt;
&amp;lt;style type='text/css'&amp;gt;
A:active
	{
	font-weight:bold;color:orange;
	text-decoration:none;
	}
A:hover
	{
        font-weight:bold;
        color:crimson;
        text-decoration:underline;
        }
UL
	{
	font-weight:bold;color:royalblue;
        }&amp;lt;/style&amp;gt;&amp;lt;title&amp;gt; echo ".$dictionary." database entry &amp;lt;/title&amp;gt;&amp;lt;body bgcolor=#EFEFEF&amp;gt;

 ";

     if(mysql_num_rows($check)&amp;gt;0)
	{
	print "&amp;lt;br&amp;gt; ".$word." already exists in ".$dictionary." database";
	}
	 else
	{
	mysql_query($query,$con)or die('couldnt execute query:'. mysql_error());
print " &amp;lt;img src=images/flags/$dictionary.png&amp;gt;&amp;amp;nbsp;&amp;lt;H1&amp;gt;&amp;lt;font color=#004080&amp;gt; $dictionary Database entry&amp;lt;/H1&amp;gt;
&amp;lt;TABLE style=\"width:250px;height:200; background:#e9e9e9;border:1px dotted #808080;color:#004080;font:12pt tahoma;\"&amp;gt;
	&amp;lt;TR BGCOLOR=#C0C0C0&amp;gt;
		&amp;lt;TD ALIGN=CENTER VALIGN=MIDDLE&amp;gt;&amp;lt;B&amp;gt;Word&amp;lt;/B&amp;gt;&amp;lt;/TD&amp;gt;
		&amp;lt;TD ALIGN=CENTER VALIGN=MIDDLE&amp;gt;$word&amp;lt;/TD&amp;gt;
	&amp;lt;/TR&amp;gt;
	&amp;lt;TR BGCOLOR=#8080C0&amp;gt;
		&amp;lt;TD ALIGN=CENTER VALIGN=MIDDLE&amp;gt;&amp;lt;B&amp;gt;Translation&amp;lt;/B&amp;gt;&amp;lt;/TD&amp;gt;
		&amp;lt;TD ALIGN=CENTER VALIGN=MIDDLE&amp;gt;$translation&amp;lt;/TD&amp;gt;
	&amp;lt;/TR&amp;gt;
	&amp;lt;TR BGCOLOR=#C0C0C0&amp;gt;
		&amp;lt;TD ALIGN=CENTER VALIGN=MIDDLE&amp;gt;&amp;lt;B&amp;gt;Word Type&amp;lt;/B&amp;gt;&amp;lt;/TD&amp;gt;
		&amp;lt;TD ALIGN=CENTER VALIGN=MIDDLE&amp;gt;$wordtype&amp;lt;/TD&amp;gt;
	&amp;lt;/TR&amp;gt;
	&amp;lt;TR BGCOLOR=#8080C0&amp;gt;
		&amp;lt;TD ALIGN=CENTER VALIGN=MIDDLE&amp;gt;&amp;lt;B&amp;gt;Dictionary&amp;lt;/B&amp;gt;&amp;lt;/TD&amp;gt;
		&amp;lt;TD ALIGN=CENTER VALIGN=MIDDLE&amp;gt;$dictionary&amp;lt;/TD&amp;gt;
	&amp;lt;/TR&amp;gt;
&amp;lt;/TABLE&amp;gt;";
       }
 		if(mysql_num_rows($checkEnglish)!=0)
                	{
			print "&amp;lt;BR&amp;gt;&amp;lt;b&amp;gt;$translation&amp;lt;/b&amp;gt; is already found in the English dictionary";
			}
                else
			{
       				mysql_query($updateEnglish,$con);
       				echo "$translation was not found in English dictionary, I just added it there.&amp;lt;br&amp;gt;";
			}



 mysql_close($con);
?&amp;gt;     &amp;lt;p&amp;gt;
&amp;lt;A href="dataentry.html"&amp;gt;Ok&amp;lt;/a&amp;gt;
&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;br /&gt;
thanks&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/phpstuff/428735/428735/data-entry/</guid>
      <pubDate>Fri, 08 Jun 2012 22:53:56 -0700</pubDate>
      <category>PHP</category>
    </item>
  </channel>
</rss>