You are here: PHP String concatination with html select combo box « PHP Programming Language « IT news, forums, messages
PHP String concatination with html select combo box

Posted by pradeep on 03/26/07 12:14

Hello,

I have problem in PHP String concatination with html select combo
box.

There are 3 files

addressbook.sql :
concat1.php
concat2.php


In concat1.php , if we select User Name in combo box & give input as 3
in
text box.
It display following output
subhash kanade,3 sk@yahoo.com

But, it is not display in that way.
So, please see that code & tell me correction.

addressbook.sql


-- Table structure for table `addressbook`
--

CREATE TABLE `addressbook` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `addressbook`
--

INSERT INTO `addressbook` (`id`, `name`, `email`) VALUES (1, 'pramod
kumar', 'pk@hotmail.com'),
(2, 'vinod wagh', 'vinod@rediff.com'),
(3, 'subhash kanade', 'sk@yahoo.com'),
(4, 'ketan patil', 'kp@hotmail.com');


concat1.php

<?php

mysql_connect("localhost","root")or die("Database Failed");
mysql_select_db("pradeep")or die("Failed to Connect Database");

$arr=array("concat(concat(name,','),id)","email");

$str="select ".$arr[0].", ".$arr[1]." from addressbook";

$res=mysql_query($str) or die("resultset error");

echo "<table><tr><th>User</th><th>Email</th></tr>";
while($row=mysql_fetch_array($res)){
echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>";
}

echo "</table>";

echo "<center>Search</center>";
echo "<form name=frm action=concat2.php method=get>";
echo "<input type=text name=txtField> <select name=selField><option
value='".$arr[0]."'>User Name</option><option value='".$arr[1]."'>E-
Mail</option></select>";
echo "<input type=submit>";
echo "</form>";
?>

concat2.php

<?

$arr1=array("concat(concat(name,','),id)","email");

$str="select ".$arr1[0].",".$arr1[1]." from addressbook where ".
$_REQUEST['selField']." like '%".$_REQUEST['txtField']."%'";

echo "<hr>Query : ".$str;

?>

Thanks in advance

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация