0

Hi

I was wondering if someone could help me.
I have a dropdown list which is populated from MySQL. The dropdown data is classed as sections. When a user selects a section from the dropdown a form on the same page is populate with the section name and they are then able to edit the section name and click save.

Its quite simple but as I have minimal PHP and MySQL I was wondering if you guys could help.

Thanks in advance

4
Contributors
12
Replies
13
Views
6 Years
Discussion Span
Last Post by JimBobUKII
0

do u want a linked drop down button or only want to edit the name selected in drop down ?????

It will be to edit whats in the drop down only. The drop down will be populated by the section table in MySQL

MySQL of Section:
section_id | Section_Name | slitingid

Results:
1233 | Home | 1
1234 | Work | 2
1235 | Away | 0
1236 | Holiday | 5

The dropdown would contain Section_Name

I hope that helps :)

Cheers

0

is this the output that you mean?

<select name="select">
<option value="">select option</option>
<option value="Home">Home</option>
<option value="Work">Work</option>
//and so on
</select>

if y then

//query from section table
$a = mysql_query("select Section_Name from Section");
echo '<select name="select">';
while($b = mysql_fetch_array($a)){
echo '<option value="'.$b['Section_Name'].'">'.$b['Section_Name'].'</option>';
}
echo '</select>';

Edited by mike_2000_17: Fixed formatting

0

this is to get drop down populated from mysql.....

<?php
$con=mysql_connect("localhost","root","")
or die("couldn't connect to mysql");
$db=mysql_select_db("abc",$con)
or die("database not found");
$result=mysql_query("SELECT name FROM aaa")
or die("query error");
echo "<select>";
while($r=mysql_fetch_array($result))
{
//echo $r['name'];
echo "<option value='".$r['name']."'>".$r['name']."</option>";
}
echo "</select>";
?>

now next part of ur problem will be done soon....i m a lil busy now...so will try it after some time....

0

this is to get drop down populated from mysql.....

<?php
$con=mysql_connect("localhost","root","")
or die("couldn't connect to mysql");
$db=mysql_select_db("abc",$con)
or die("database not found");
$result=mysql_query("SELECT name FROM aaa")
or die("query error");
echo "<select>";
while($r=mysql_fetch_array($result))
{
//echo $r['name'];
echo "<option value='".$r['name']."'>".$r['name']."</option>";
}
echo "</select>";
?>

now next part of ur problem will be done soon....i m a lil busy now...so will try it after some time....

Thanks so far! I appreciate your help

0

if i give u remaining code tomorrow...will it be ok....at present i m busy with my college stuff.....

0

if i give u remaining code tomorrow...will it be ok....at present i m busy with my college stuff.....

Not a problem at all. I am grateful for the help

0

if i give u remaining code tomorrow...will it be ok....at present i m busy with my college stuff.....

Hi Tomato, wondered if you had an update for me?

Cheers

0

ok....ur work is done..here is the code i used...it was becoming conjusted in a page so i used second page although we can do it using a single page only....

HERE's UR CODE

1.php

<?php
$con=mysql_connect("localhost","root","")
or die("couldn't connect to mysql");
$db=mysql_select_db("abc",$con)
or die("database not found");
$result=mysql_query("SELECT name FROM aaa")
or die("query error");
echo "<form action='' method='GET'>";
echo "<select name='s'>";
while($r=mysql_fetch_array($result))
{
//echo $r['name'];
echo "<option value='".$r['name']."'>".$r['name']."</option>";
}
echo "</select>";
echo "<input type='submit' value='submit' name='submit'>";
echo "</form>";
if(isset($_GET['s']))
{echo "<form action='abc.php'>";
echo "<input type='text' value='".$_GET['s']."' name='a'>";
echo "<input type='submit' value='submit' name='submit'>";
echo "<input type='hidden' value='".$_GET['s']."' name='b'>";
echo "</form>";
}
?>

abc.php

<?php
$con=mysql_connect("localhost","root","")
or die("couldn't connect to mysql");
$db=mysql_select_db("abc",$con)
or die("database not found");
$result=mysql_query("UPDATE aaa SET name='".$_GET['a']."' where name='".$_GET['b']."'")
or die("query error");
header("Location:1.php");
?>

if it's useful...just respond positive to it....
and if ur problem is solved mark the thread solved and u can at any time PM me for any assisstance....

0

I suggest using a ".=" to build the select options as opposed to echoing everything out:

$options ="";
while(...){
  $options .= "\t<option value=\"...\">...</option>\n";
}

The later on, you can insert it in general html. Otherwise creating a basic html file gets really messy with four million echoes!

<select id="..." name="...">
<?php echo $options;?>
<select>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.