1

My code is like so:

$run = $dbcon->query("SELECT * FROM sometable");
  while ($beef = $run->fetch_assoc()){
    $theid = $beef['id'];
    $patty = $beef['part'];
    $current = POST['$theid'];

    echo "<form name='$theid'>$patty</form>";
  }

What this code is going to do is echo as many forms as I have rows in my sometable column part and show them all in my HTML (I suppose it bears mentioning that this is not proper HTML. Hopefully it is understood that for this example it is not the point).

Now, I would like to add something like $current = $_POST['$theid'] so that when making a db call, I can differentiate the various echo instances of the row's id. And I would like my $current variable to hold the correct instance of my id.

How might I approach this goal? Is a loop necessary? If so, how might that look?

0

1 Answer 1

3

1st : simple add it in hidden input field

2nd : Need a submit button for each form

Form:

  echo "<form name='$theid'>
         <input type='hidden' name='id' value='".$theid."' />
         <input type='submit' name='submit' value='submit' />
         </form>";
Sign up to request clarification or add additional context in comments.

1 Comment

Much more verbose than mine! Lazy Friday! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.