logintech Posted January 13, 2012 Share Posted January 13, 2012 Hello everyone I have two dropdown lists. First one you can see the tables of my db and the second one the files inside a folder. The problem is that i can't send my selections from the dropdown list to an other file. My project is to choose a table, then a CSV file and then load the file in db. index.php: <?php //EMFANISH PINAKWN include("../forma/dbCon.php"); echo "<form action='load_table_test.php' method='POST'>"; $sql="SHOW TABLES FROM misthodosia"; $result=mysql_query($sql); if (!$result) { echo "Υπάρχει πρόβλημα με την βάση\n"; echo 'MySQL Error: ' . mysql_error(); exit; } echo"<select>"; while ($row = mysql_fetch_row($result)) { echo "<option name='{row[0]}' value='{row[0]}'>{$row[0]}</option>"; } echo"</select>"; mysql_free_result($result); //==========================EMFANISH ARXEIWN========================== function populateDropdown(){ $path = glob("C:\\xampp\\htdocs\\dbadmin\\upload_files\\*"); //the double \\ is not a typo you //have to escape it //if the path cannot be found if(!($path)){ echo("Δεν υπάρχει ο φάκελος"); return; }//if //the path is valid else{ foreach($path as $k){ $i = basename($k); echo "<option name='$i'>".$i."</option>"; }//foreach }//else }//populateDropdown echo"<select>"; populateDropdown(); echo"</select> "; echo"<input type='submit' name='submit' value='Φόρτωσε1111111' />"; echo "</form>"; $hello="hello"; ?> load_table_test.php: <?php include("../forma/dbCon.php"); echo $_POST['hello']; echo $_POST['{row[0]}']; echo $i; //$pinakas=$_POST['pinakas'] //$arxeio=$_POST['arxeio'] //$pinakas=$_POST['row'] //$arxeio=$_POST['diadromi'] //mysql_query("LOAD DATA LOCAL INFILE "$arxeio" INTO TABLE $pinakas //FIELDS //TERMINATED BY ',' //ENCLOSED BY '\"' //LINES TERMINATED BY '\n') echo "$arxeio"; echo "$pinakas"; echo "<br/><br/><br/><br/><br/><a href='index.php'>Επιστροφή στην προηγούμενη σελίδα.</a>"; ?> errors: Notice: Undefined index: hello in C:\xampp\htdocs\dbadmin\load_table_test.php on line 6 Notice: Undefined index: {row[0]} in C:\xampp\htdocs\dbadmin\load_table_test.php on line 8 Notice: Undefined variable: i in C:\xampp\htdocs\dbadmin\load_table_test.php on line 9 Notice: Undefined variable: arxeio in C:\xampp\htdocs\dbadmin\load_table_test.php on line 27 Notice: Undefined variable: pinakas in C:\xampp\htdocs\dbadmin\load_table_test.php on line 28 Link to comment https://forums.phpfreaks.com/topic/254932-dropdown-list-with-db-tables-and-files/ Share on other sites More sharing options...
Muddy_Funster Posted January 13, 2012 Share Posted January 13, 2012 when refferencing drop down lists from a form into a variable you would do it by pointing to the name of the select element, not the option. An attempt to make this clearer: $_POST['textbox1'] => 'hello' would come from a form field like so: <input type="text" name="textbox1" value ="hello" > $_POST['dropdown1'] => 'second Option' would come from a drpdown field like so: <select name="dropdown1"> <option value="First Option">1st Option</option> <option value="Second Option" selected="selected">2nd Option</option> </select> Hope that helps. Link to comment https://forums.phpfreaks.com/topic/254932-dropdown-list-with-db-tables-and-files/#findComment-1307147 Share on other sites More sharing options...
logintech Posted January 13, 2012 Author Share Posted January 13, 2012 i tested this but: Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting ',' or ';' in C:\xampp\htdocs\dbadmin\load_table_test.php on line 6 Link to comment https://forums.phpfreaks.com/topic/254932-dropdown-list-with-db-tables-and-files/#findComment-1307149 Share on other sites More sharing options...
Muddy_Funster Posted January 13, 2012 Share Posted January 13, 2012 Could you post the code that geve that error. Link to comment https://forums.phpfreaks.com/topic/254932-dropdown-list-with-db-tables-and-files/#findComment-1307160 Share on other sites More sharing options...
logintech Posted January 13, 2012 Author Share Posted January 13, 2012 keep this in mind: echo "<option name='row[0]' value='row[0]'>{$row[0]}</option>"; in second file i change this: echo $_POST['{row[0]}']; to this: echo $_POST['row[0]']=>row[0]; and this is where the error is Link to comment https://forums.phpfreaks.com/topic/254932-dropdown-list-with-db-tables-and-files/#findComment-1307162 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.