Jump to content

Assign large data to Varialble


mrbad

Recommended Posts

Hello,

 

I want to assign large data - say 500-600 lines which contains data and html tags to X variable, which will parse the data to translation function (google api) and data will be translated.

 

Please help.

 

Thanks in advance,

Vikram

Link to comment
Share on other sites

Hello,

 

Here is the data file (30% data only) - hope it helps ::)

 

<?
$products1="<div style='width:890px; float:left;'><div class='procoltitle1'>Products</div><div class='procoltitle2'>Standard</div><div class='procoltitle1'>Package</div><div class='procoltitle2'>CAS No.</div><div class='procolodd1'>Acyclovir</div><div class='procolodd2'>E.P/B.P/USP</div><div class='procolodd1'>25/50 HDPE Drums</div><div class='procolodd2'>59277-89-3</div><div class='procoleven1'>Artesunate</div><div class='procoleven2'>I.H.S.</div><div class='procoleven1'>1/5/25/50/100 KG.</div><div class='procoleven2'>88495-63-0</div><div class='procolodd1'>Artemether</div><div class='procolodd2'>I.H.S.</div><div class='procolodd1'>1/5/25/50/100 KG.</div><div class='procolodd2'>72963-77-4</div><div class='procoleven1'>Sodium Stearyl Fumarate</div><div class='procoleven2'>U.S.P.</div><div class='procoleven1'>5/10/25/50 KG HDPE Drums</div><div class='procoleven2'>4070-80-8</div><div class='procolodd1'>Alpha-Beta Arteether</div><div class='procolodd2'>I.H.S.</div><div class='procolodd1'>1/5/25/50/100 KG.</div><div class='procolodd2'>75887-54-6</div><div class='procoleven1'>Amoxicillin Tri Hydrate</div><div class='procoleven2'>B.P./I.P.</div><div class='procoleven1'>25/50 KG HDPE Drums</div><div class='procoleven2'>26787-78-0</div></div>";
?>

 

Thanks,

Vikram

Link to comment
Share on other sites

Hello,

 

Here is the data file (30% data only) - hope it helps ::)

 

<?
$products1="<div style='width:890px; float:left;'><div class='procoltitle1'>Products</div><div class='procoltitle2'>Standard</div><div class='procoltitle1'>Package</div><div class='procoltitle2'>CAS No.</div><div class='procolodd1'>Acyclovir</div><div class='procolodd2'>E.P/B.P/USP</div><div class='procolodd1'>25/50 HDPE Drums</div><div class='procolodd2'>59277-89-3</div><div class='procoleven1'>Artesunate</div><div class='procoleven2'>I.H.S.</div><div class='procoleven1'>1/5/25/50/100 KG.</div><div class='procoleven2'>88495-63-0</div><div class='procolodd1'>Artemether</div><div class='procolodd2'>I.H.S.</div><div class='procolodd1'>1/5/25/50/100 KG.</div><div class='procolodd2'>72963-77-4</div><div class='procoleven1'>Sodium Stearyl Fumarate</div><div class='procoleven2'>U.S.P.</div><div class='procoleven1'>5/10/25/50 KG HDPE Drums</div><div class='procoleven2'>4070-80-8</div><div class='procolodd1'>Alpha-Beta Arteether</div><div class='procolodd2'>I.H.S.</div><div class='procolodd1'>1/5/25/50/100 KG.</div><div class='procolodd2'>75887-54-6</div><div class='procoleven1'>Amoxicillin Tri Hydrate</div><div class='procoleven2'>B.P./I.P.</div><div class='procoleven1'>25/50 KG HDPE Drums</div><div class='procoleven2'>26787-78-0</div></div>";
?>

 

Thanks,

Vikram

 

dude

try this

<?php
echo $products1= "    <div style=\'width:890px; float:left;\'><div class=\'procoltitle1\'>Products</div><div class=\'procoltitle2\'>Standard</div><div class=\'procoltitle1\'>Package</div><div class=\'procoltitle2\'>CAS No.</div><div class=\'procolodd1\'>Acyclovir</div><div class=\'procolodd2\'>E.P/B.P/USP</div><div class=\'procolodd1\'>25/50 HDPE Drums</div><div class=\'procolodd2\'>59277-89-3</div><div class=\'procoleven1\'>Artesunate</div><div class=\'procoleven2\'>I.H.S.</div><div class=\'procoleven1\'>1/5/25/50/100 KG.</div><div class=\'procoleven2\'>88495-63-0</div><div class=\'procolodd1\'>Artemether</div><div class=\'procolodd2\'>I.H.S.</div><div class=\'procolodd1\'>1/5/25/50/100 KG.</div><div class=\'procolodd2\'>72963-77-4</div><div class=\'procoleven1\'>Sodium Stearyl Fumarate</div><div class=\'procoleven2\'>U.S.P.</div><div class=\'procoleven1\'>5/10/25/50 KG HDPE Drums</div><div class=\'procoleven2\'>4070-80-8</div><div class=\'procolodd1\'>Alpha-Beta Arteether</div><div class=\'procolodd2\'>I.H.S.</div><div class=\'procolodd1\'>1/5/25/50/100 KG.</div><div class=\'procolodd2\'>75887-54-6</div><div class=\'procoleven1\'>Amoxicillin Tri Hydrate</div><div class=\'procoleven2\'>B.P./I.P.</div><div class=\'procoleven1\'>25/50 KG HDPE Drums</div><div class=\'procoleven2\'>26787-78-0</div></div>";
?>

Link to comment
Share on other sites

Hi,

 

I have already tried this but no luck - since data to be assigned to variable is very large (more then 500-600lines) and since variable has limitation of 157 characters only - it wont work  :'(

 

Thanks anyways :)

Vikram

Link to comment
Share on other sites

[...] since variable has limitation of 157 characters only

 

well that would be the kind of limitation one could eventually encounter on Windows...

but never heard about something like that for PHP... sounds like nonsense

 

I am guessing there is something wrong with your code...

but you should post it so that we could have a look at it...

 

Link to comment
Share on other sites

Hello,

 

Friends, thank you so much for your kind support. Here are the codes for php and have also attached text file - to have an idea of how large data is to be assigned to variable.

 

index.php

<?
$page="pharma";
require 'content/'.$page.'.php';
require "inc/functions.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Parth : Translation</title>
<script type="text/javascript" src="js/jsapi"></script>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<!-- LANGUAGE FLAG STARTS -->
<? echo languagemenu(); ?>
<!-- LANGUAGE FLAG ENDS-->

<br />
<h1>Parth</h1>

<!-- CONTENT AND TRANSLATION STARTS-->
<? 
		$txtid="1";
		$txt="$products1";
		echo content1($txtid, $txt);
?>
<!-- CONTENT AND TRANSLATION ENDS -->

</body>
</html>

 

function.php

//MAIN TRANSLATION 
function translate($txt, $txtid)
{
global $self;
$self=$_SERVER['PHP_SELF'];
global $lang;
global $txt;
global $page;

echo'
<!-- MESSAGE TRANSLATION STARTS-->
<script type="text/javascript">

    google.load("language", "1");

function toptext() {
      google.language.translate("'.$txt.'", "en", "'.$lang.'", 
  
  
  function(welcomemsg) {
        if (!welcomemsg.error) {
          var container = document.getElementById("'.$txtid.'");
          container.innerHTML = welcomemsg.translation;
        }
      });
    }
    google.setOnLoadCallback(toptext);

    </script>
<!--  MESSAGE TRANSLATION ENDS-->	 ';
}

//TRANSLATION 1
function content1($txtid, $txt)
{
		global $txtid;
		global $txt;
		echo' <div class="contentbox" id="'.$txtid.'">';
		echo translate($txt, $txtid); 
		echo '</div>';
}

 

Thanks,

Vikram

 

[attachment deleted by admin]

Link to comment
Share on other sites

the length of the text should not be an issue...

try like this:

function content1($txtid, $txt)
{
global $txtid;
global $txt;

return '<div class="contentbox" id="'.$txtid.'">' . 
	translate($txt, $txtid) . 
	'</div>';
}

 

and

 

function translate($txt, $txtid)
{
// [...]

return '
<!-- MESSAGE TRANSLATION STARTS-->
<script type="text/javascript">
    google.load("language", "1");
function toptext() {
      google.language.translate("'.$txt.'", "en", "'.$lang.'", 

  function(welcomemsg) {
        if (!welcomemsg.error) {
          var container = document.getElementById("'.$txtid.'");
          container.innerHTML = welcomemsg.translation;
        }
      });
    }
    google.setOnLoadCallback(toptext);

    </script>
<!--  MESSAGE TRANSLATION ENDS--> ';
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.