noobphp Posted March 3, 2011 Share Posted March 3, 2011 hi i am a newby here and i am trying to learn how to use php. i have a drop down menu wich loads the tables into the dropdown meny from MySql, when i open the drop down menu i am able to click an item based on the aboutId i have chosen so it shows me the aboutTitle ( thats the titlename i used ) . but now is my question how do i pull all the data based on what i select in my text fields? sounds easy right?.. well not yet for me.. can anyone give me pointers and or help me out with it? i use DW to help me along but its not quiet good enough..yeah i know the code is ugly but its a start for me .. this is what i have so far : php: <?php require_once('../Connections/db_config.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_db_config, $db_config); $query_rsAbout = "SELECT aboutId, aboutTitle, aboutStory, aboutGraphic, aboutFooter, visiblePage FROM about"; $rsAbout = mysql_query($query_rsAbout, $db_config) or die(mysql_error()); $row_rsAbout = mysql_fetch_assoc($rsAbout); $totalRows_rsAbout = mysql_num_rows($rsAbout); // end php ?> html: drop down menu : <select name="aboutSelect" class="aboutListmenu"> <option value="">-- Select --</option> <?php do { ?> <option value="<?php echo $row_rsAbout['aboutId']?>"><?php echo $row_rsAbout['aboutTitle']?></option> <?php } while ($row_rsAbout = mysql_fetch_assoc($rsAbout)); $rows = mysql_num_rows($rsAbout); if($rows > 0) { mysql_data_seek($rsAbout, 0); $row_rsAbout = mysql_fetch_assoc($rsAbout); } ?> </select> one of the input fields : <input name="aboutTitle" type="text" id="aboutTitle" value="<?php echo $row_rsAbout['aboutTitle']; ?>" /> bla bla.. can anyone give me pointers and or help me out with it? Link to comment https://forums.phpfreaks.com/topic/229488-populate-textfields-with-a-danamic-dropdown-listmenu-data-from-mysql/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.