473,467 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PHP String concatination with html select combo box

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, 'pradeep
kulkarni', 'p******@cotmac-proex.com'),
(2, 'vinod wagh', 'v****@rediff.com'),
(3, 'subhash kanade', 's*@yahoo.com'),
(4, 'ketan patil', 'k*@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

Mar 26 '07 #1
0 2314

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Erik Grob \(MCP\) | last post by:
Does anyone know where to find or how to write a quick user defined fucntion that will return a table object when passed the string name of the table object. The reason why I want dynamicallly set...
2
by: HumanJHawkins | last post by:
The following query works perfectly (returning all words on a list called "Dolch" that do not contain a form of "doing"): SELECT 'Dolch' AS , dbo.Dolch.vchWord FROM dbo.Dolch LEFT OUTER JOIN...
4
by: Richard Haygreen | last post by:
I have an HTML form which includes a combo box with 4 options, which is used to select a method of contact (phone, email etc...). If the user selects an invalid option (for example, they have...
1
by: SAN CAZIANO | last post by:
how can clear an html SELECT and next insert in it all the elements of an array () I try this but seems doesn't works. function ComboAddArrayValueWithLabel(combo,ArrayLabel,ArrayValue) { ...
5
by: Alpha | last post by:
Is there any way to create a new column in a dataset table from 2 string column and a int column? I got an error "expecting string" from my code below. Any help would be appreciated. ...
8
by: Two Beards | last post by:
Hi, I'm new to VB and .net so I may be mising something. I am trying to dynamically build some SQL by appending to a string. Part of the SQL comes from an mp3 id tag I have extracted from a file...
23
by: Bonj | last post by:
what is the correct form of string concatenation in VB.NET, + or &? Both seem to work, but which is correct? I know it's + in C# and & in VB6, but which in VB.NET?
2
by: pradeep | last post by:
Hi, I have a problem in PHP about Query of concating. Please, guide me 1: test.sql is dump file -- PHP Version: 4.4.2 -- -- Database: `pradeep`
0
by: pradeep | last post by:
Hello, I have problem in PHP String concatination with html select combo box. There are 3 files addressbook.sql : concat1.php concat2.php
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.