Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

puzzledking

macrumors newbie
Original poster
Oct 17, 2014
1
0
i have
editlistingnew.php
PHP:
<?php 
include_once 'EditSittingList.php';
connect()
?>

<body>

<select id="sel_SittingType" name="sel_SittingType" >
		<?php 
		dropboxlist()
		?>
	</select>
    
    <textarea rows="4" cols="50">
</textarea>
    
    <?php close()?>
</body>



and editsittinglist.php
PHP:
<?php
include 'db.php';
?>
<body>
<?php
function connect(){	 
	  mysql_connect(DB_HOST,DB_USER,DB_PASS) or die('could not connect' . mysql_error());
       mysql_select_db(DB_NAME);
	   }

function dropboxlist(){
$result = mysql_query ("SELECT SitterType FROM POSTS WHERE UserName = 'mike'"); 
		 while ($record = mysql_fetch_array($result)){
		 echo '<option value="' . $record['SitterType'] . '">' .$record['SitterType'] . ' </option>';
		 }    
	}
	
function textboxarea(){		
}
	
function close(){
	mysql_close();
}
?>

with databas 3 columns UserName SitterType and SitterAvailiable, currently the dropbox works perfectly in gets the array and displays them. but what i want is when a user selects the sitter type to be 'baby' i want the text box/area to update with whats in the database.
 
You need to define a form in your html to give the selection back with either a GET or a POST request. Next you have to read the data from the request and define your textboxarea function to fetch the matching data by defining your SitterType as an additional WHERE clause. But please sanitize/escape every parameter you use in your SQL query in order to avoid SQL injection (with MySQL look right here for example).
By the way, there is a second <body> tag in your EditSittingList.php that shouldn't be there.
Generally speaking you should use a PDO connection, this makes stuff a lot easier when getting into OOP (Object Orientated Programming). I recommend you to work with classes right away.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.