basil60 Posted September 8, 2015 Share Posted September 8, 2015 Hi I wrote the code in attachment and it works quite well. It can be viewed live here. It merely goes to a lookup table, and pulls some pre-determined values for Salute and puts them in a drop down box. One of my students used it as template, and it returns a bunch of errors - echoing code, rather than values. The result of that can be seen here. I've analysed it, and can't see anything that resembles an error. She is trying to pull the values of reviewer name from another table (reviewer) and place the selected value for reviewerid into the table she's updating. The code is below. <form enctype="multipart/form-data" method="post" action="add_reviewparts.php"> <td> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <!----------------------------------------------------> <tr> <td width="117">firstname</td> <td width="14">:</td> <td width="357"> <?php require ("dbcnx.php"); $get_type = mysql_query("SELECT reviewerid, firstname FROM reviewer"); /* create form containing selection list */ echo"<select name='reviewerid'>"; while ($row = mysql_fetch_array($get_type)) { extract($row); echo '<option value="'.$row['firstname'].'" >'.$row['firstname'].'</option>'; } echo "</select>"; ?> </td> </tr> <!----------------------------------------------------> </tr> <tr> <td width="117">starrating</td> <td width="14">:</td> <td width="357"><input name="starrating" type="text" id="type" size="5" /></td> </tr> <tr> <td width="117">reviewtitle</td> <td width="14">:</td> <td width="357"><input name="reviewtitle" type="text" id="type" size="25" /></td> </tr> I'd prefer to continue with this "way of doing it" - other advice suggested I go with PDO. I'm on a time constraint, so I'd like to tidy up with what I know, rather than falling in a heap and running out of time. I'd appreciate any advice you may be able to give. Basil traveller_drop2.html Quote Link to comment https://forums.phpfreaks.com/topic/298093-pulling-values-from-a-table-using-html-form-select-option/ Share on other sites More sharing options...
requinix Posted September 8, 2015 Share Posted September 8, 2015 (edited) The file is named "reviewparts.html" and that server isn't configured to execute .html files as PHP code. If you look at the source of the page you'll see the full PHP code - as if it weren't even executed at all. Try simply renaming it to "reviewparts.php". Edited September 8, 2015 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/298093-pulling-values-from-a-table-using-html-form-select-option/#findComment-1520476 Share on other sites More sharing options...
hansford Posted September 8, 2015 Share Posted September 8, 2015 If you absolutely need the html extension you can add an .htaccess file to the folder with the following code: RewriteEngine on RewriteRule ^(.*)\.html $1\.php However, simply naming it with the correct extension would be the better option. Quote Link to comment https://forums.phpfreaks.com/topic/298093-pulling-values-from-a-table-using-html-form-select-option/#findComment-1520477 Share on other sites More sharing options...
basil60 Posted September 8, 2015 Author Share Posted September 8, 2015 Thanks I wasn't aware that only some servers parsed html as PHP. Appreciate your clear answer. Quote Link to comment https://forums.phpfreaks.com/topic/298093-pulling-values-from-a-table-using-html-form-select-option/#findComment-1520478 Share on other sites More sharing options...
requinix Posted September 8, 2015 Share Posted September 8, 2015 It's very much a per-server thing, and you'll find that most servers only allow .php (and occasionally .php5) so that's the most reliable extension to use. However you can often add some configuration, even as just a regular user, that will allow it. Quote Link to comment https://forums.phpfreaks.com/topic/298093-pulling-values-from-a-table-using-html-form-select-option/#findComment-1520504 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.