Jump to content

Having a little problem


Schlo_50

Recommended Posts

Hi all,

 

I am having a problem with a certain hidden field. This hidden field needs to hold the value $name, but I don't want it to be inside my foreach loop. However, If I have it outside of my foreach loop the variable $name isn't assigned the value it is meant to. Im not sure how else to explain this, so my code is as follows. It should become clearer when you see the commented line I have included.

 

print "<select name=\"manufacturer\" class=\"form\">";
print "<option value=\"none\" selected=\"selected\">Not Applicable</option>";

$linesb = file("data/manufacturers.DAT");
foreach ($linesb as $lineb) { 
$datab = explode("|", $lineb);

$mid = trim($datab[0]);
$name = trim($datab[1]);   
  
print "<option value=\"$mid\">$name</option>";
}
// $name below takes on the last value in my .DAT list because it is outside of the loop.
print "<input type=\"hidden\" name=\"manhide\" value=\"$name\" class=\"form\">";
print "</select>";

 

Thanks in advance guys!

Link to comment
Share on other sites

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.