Jump to content

MySQL Query from echo


Bradley99

Recommended Posts

I have some code, in which I echo a form. From the form users pick different things. . .

<?
   $showevent = mysql_query("SELECT * FROM fights WHERE event='$viewevent' ORDER by id ASC");
   while($the=mysql_fetch_object($showevent)){ 
   

   
  echo "  <form action='' method='post'><tr><td class='profilerow'><input type=radio name=fighter_id value=$the->fighter1> $the->fighter1 <BR> <input type=radio name=fighter_id value=$the->fighter2> $the->fighter2 <BR> <input type=radio name=fighter_id value=1> Draw</td>
	  <td class='profilerow'><select name=method><option value=KO>Knockout</option><option value=TKO>Technical Knockout</option><option value=DEC>Decision</option></select></td>
	  <td class='profilerow'><select name=round><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option></select></td>
	  <td class='profilerow'><select name=bonus><option value=1>Yes</option><option value=2>No</option></td>	  
	  <td class='profilerow'><input type='Submit' name='Submit' value='Pick' class='Submit' /> </td></form>

   </tr>"; } ?>

 

When they choose 'Pick' for each fight, How can I, using INSERT INTO, insert the ID of that specific fight? As the fights are being echoed.

 

I have Events table, Fights table & Fighters table. Aswell as the picks table that this info gets posted to.

Link to comment
Share on other sites

It's actually difficult to understand your problem, as you've given no information on how your DB is designed. However as I see it, the simplest solution is probably to add a <input type="hidden" /> to your form, which is passed on when the form is submitted.

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.