Hello,i m newer to the php.
my problem is...
i have one form with textfield and multiple selection listbox. i select multiple values form listbox, implode it with comma and put all values in single database field. its working.
But, i cant retrieve them with explode function . i want to put all array's values in listbox , but with selected, so that the user can get an idea about previous selection.
Could anyone please help me?
Pooja J.
0
Light Poster
Recommended Answers
Jump to PostFollowing code may help you
<html> <body> <form> <!-- copy following php code at the place where you are populating your list box--> <?php /* set $mywholearray from database this array contains all master values to be shown in listbox $mywholearray[0]['id']='pkvalue', $mywholearray[0]['desc']='description', */ /*set $myselarray from database …
Jump to Post<? $cat=$city; //fetch $city according to ur query. $catrr=explode(",",$cat); //explode. //echo $catrr; ?> <select name="t_city[]" size="5" multiple="multiple" class="normal_text" id="t_class" style="width: 150px;"> <? if(!$_SESSION[user]) { ?> <option selected="selected" value="select">Select Class</option> <? } ?> <? $cat_query=mysql_query("select * from city "); while($cat_data=mysql_fetch_array($cat_query)) { ?> <option value="<?=$cat_data['city'] ?>"<?if(in_array($cat_data['city'],$catrr)) {?> selected="selected" <? …
Jump to Post//insert.php
<?php
$con=mysql_connect("localhost","root","");
$db=mysql_select_db('state');
$name=$_POST;
//$city=$_POST;
$abc=$_POST;
for ($i=0; $i<count($abc); $i++)
{
$city = $city." ".$abc[$i];
}
$submit=$_POST;
if(!empty($submit))
{$query=mysql_query("insert into city(name,city) values('$name','$city')");
}?>
Above code is working. But the problem is that, I want listbox on another page, this listbox should display the name of all cities, …
All 10 Replies
urtrivedi
276
Nearly a Posting Virtuoso
Pooja J.
0
Light Poster
pushpakalpana
1
Newbie Poster
muralibobby2015
17
Posting Pro
Pooja J.
0
Light Poster
muralibobby2015
17
Posting Pro
Pooja J.
0
Light Poster
muralibobby2015
17
Posting Pro
rajabhaskar525
1
Junior Poster
urtrivedi
276
Nearly a Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.