Jump to content

Pulling values from a table using HTML form select option


Recommended Posts

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

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 by requinix

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.