Jump to content

different query for same variable


BluwAngel

Recommended Posts

okay i have table named ZAMJENE with 2 rows only row that i need to setup is named id_zamjena and have values 15 and 16

 

when i do echo on page it work great but when i press button i get only 16 for both entries

 

full cde is too long so i paste only important parts

$query_zamjene = mysql_query ("SELECT * FROM zamjene  WHERE id_user_1='$moj_id' AND zamjenjeno='0' ORDER BY id_event_1");

echo "<form method='post' action='event_zamjenjen.php'>";


while ($rows = mysql_fetch_array($query_zamjene))
{
$id_zamjena	= $rows['id_zamjena'];
$id_event_1	= $rows['id_event_1'];
$id_event_2	= $rows['id_event_2'];
$id_user_2	= $rows['id_user_2'];

echo "$id_zamjena";   // THIS ROW WORKS CORRECTLY
echo "<input name='id_zamjena' type='hidden' value=$id_zamjena>";  // output of this is always 16

echo "<input name='response' type='submit' value='Prihvati zamjenu' />
<input name='response' type='submit' value='Odbaci zamjenu' />
<br>";

}
echo"</form>";



 

Link to comment
Share on other sites

When you have multiple inputs of the same name in a form, only the LAST one will be submitted when you submit the form.  You must name your input name='id_zamjena[]', then $_POST['id_zamjena'] will be an ARRAY of these inputs.

 

-Dan

Link to comment
Share on other sites

It's very hard to help you due to a language barrier. I am having troubles even figuring out what you're trying to do.

 

ManiacDan has already told you that using his method will result in an array. If you don't understand how arrays work, you should start there. Since the $_POST variable is an array, it's quite important to understand how it works before using.

 

http://oreilly.com/catalog/progphp/chapter/ch05.html

 

You may want to explain exactly what you're trying to do, we may be able to assist more accurately.

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.