473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Question about Arrays from php and arrays from mysql

1
Hello, i'm trying to create a simple converter application using php. The main function i use is strtr() that can translate from $string via arrays.

Because the arrays need to add in the file php, so it is difficult to user add their own word in this application. I was create a database that contain 2 fields. The question is how the script to write.


[PHP]

$phonArray=array(
'abaian'=>'اباين','abbas'=>'عباس','abd'=>'عبد','ab dal'=>'ابدال','abdas'=>'ابدس','abdi'=>'عبدي',);

$input="Some Texts Here....";//from form

//How to make this $input read from the database first and then proceed to next function strtr() bellow.

$output= strtr($input, $phonArray);

echo"$output";

[/PHP]
Jan 8 '07 #1
1 1244
b1randon
171 Expert 100+
Hello, i'm trying to create a simple converter application using php. The main function i use is strtr() that can translate from $string via arrays.

Because the arrays need to add in the file php, so it is difficult to user add their own word in this application. I was create a database that contain 2 fields. The question is how the script to write.


[PHP]

$phonArray=array(
'abaian'=>'اباين','abbas'=>'عباس','abd'=>'عبد','ab dal'=>'ابدال','abdas'=>'ابدس','abdi'=>'عبدي',);

$input="Some Texts Here....";//from form

//How to make this $input read from the database first and then proceed to next function strtr() bellow.

$output= strtr($input, $phonArray);

echo"$output";

[/PHP]
[PHP]
//your array
$phonArray=array(
'abaian'=>'اباين','abbas'=>'عباس','abd'=>'عبد','ab dal'=>'ابدال','abdas'=>'ابدس','abdi'=>'عبدي',);

//database info
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';

//connect to db
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

//select db & run query
$dbname = 'translator';
mysql_select_db($dbname);
$result = mysql_query('SELECT * WHERE ID="0"');
$row = mysql_fetch_row($result);
$input = $row[0];

//close db
mysql_close($conn);

//continue
$output= strtr($input, $phonArray);

echo"$output";
[/PHP]
Jan 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ralph Freshour | last post by:
I want to write a listbox sized to 8 rows - I want to show summaries in this listbox and when an item is selected, below I want to show the details of the summary - I can trap a javascript event...
0
by: James | last post by:
Hi, I have the following code: <PRE> <?php $username = "####t"; $password = "####"; $hostname = "####"; mysql_connect($hostname, $username, $password) or die("Unable to connect to
12
by: James | last post by:
Hi, Have posted before, but will simplify problem here. For original post go to http://forums.devshed.com/t80025/s.html I have setup 2 arrays like so in my one page script: $carers =...
1
by: jonnytansey2 | last post by:
Can anyone out there give me a pointer regarding creating a dynamically-generated drop-down list connected to an array? And is that question as clear as chocolate spread? Here's what I've got....
15
by: Good Man | last post by:
Hey there I have a dumb question.... Let's say i have a database full of 4000 people.... I select everything from the database by: $result = mysql_query("SELECT * FROM People");
1
by: Grant Collins | last post by:
Hi, I am writing a client / server application for one of my University projects and I would like some guidance reguarding the transfer of data from the client to the server. I have two...
4
by: mantrid | last post by:
Im using arrays generated from my records displayed in a table on my site to update the corresponding records in a mysql database ie on the web page col1 col2 col3 1 2 2 1 ...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
12
by: Martien van Wanrooij | last post by:
I have been using for a while a class to create photo albums. Shortly, an array of photo's is declared, initially they are shown as thumbnails, by clicking on a thumbnail a larger photo is shown...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.