PHP String concatination with html select combo box

This is a discussion on PHP String concatination with html select combo box within the PHP Language forums, part of the PHP Programming Forums category; Hello, I have problem in PHP String concatination with html select combo box. There are 3 files addressbook.sql : concat1....


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2007
pradeep
 
Posts: n/a
Default 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', 'pradeep@cotmac-proex.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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:14 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0