Jump to content

Help with dynamically created table with related fields


mlummus

Recommended Posts

I'm trying to create a table form that pulls in "Extra" choices from a table and allows users to select a number of days and number of guests for each choice. I started creating it a a checkbox field but am thinking just using the name as a label and setting days and guests to default "0" might be a better bet. Guidance from someone more experienced with this? Also, how do I store the submission (db structure - in the "reservations" table, another?). I'm new to this and feel kind of lost with this challenge.

 

//Extras
$query = "select * from extras";
$data = mysqli_query($db, $query);
$num = mysqli_num_rows($data);

echo "<p><b>Extras:</b></p>";
for ($i=0; $i<$num; $i++)
{
$row = mysqli_fetch_array($data);
$extra_id = $row['extra_id'];
$extra_name = $row['extra_name'];
$extra_rate = $row['extra_rate'];

echo "<p><input type='checkbox' name='extra_id[]' value = '$extra_id'
/>$extra_name <i>\$$extra_rate</i>  Num Days<input type='text' name='d$extra_id' />  Num Guests<input type='text' name='g$extra_id' />";
}

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.