LB1234
asked on
Setting up unique names (for MySQL functionality) for each entry in a table pulled from a database
Please look at the attached image. Each row in this table is being pulled from a database. But in order to save the entered information (various notes entered, whether something has been checked "done" or not, and the entered value for the drop down list shown here) each element on each line must have a unique name for the processing page right? So the first line, would have a form name of "note1" and "note2" -- they cannot both be called "note" correct? Conceptually, how do I accomplish this? A foreach statement or something?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It looks like the textarea is the field you need the array for so do it this way:
<textarea name="name[]"...
Then when it is sunmited you will have an array in the $_POST variables and can reference as:
$_POST['name[0]'], $_POST['name[1]'], etc
Cd&
<textarea name="name[]"...
Then when it is sunmited you will have an array in the $_POST variables and can reference as:
$_POST['name[0]'], $_POST['name[1]'], etc
Cd&
ASKER
Ah, thanks COBOL!
Can you please shed some light on the PHP code and SQL statement I'd use?
Can you please shed some light on the PHP code and SQL statement I'd use?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The only time during any given day when I feel like a complete idiot is when I'm trying to code/learn PHP. I'm a network administrator learning this stuff on my own and PHP is my first language. I should be compensated for the ongoing battery of my ego! Guys, I will pore over the helpful code provided and try to understand it. Will get back to you soon, thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here's the code for the entire thing.
<form action="process_table.php"
<table>
<tr>
<th scope="col">Date</th>
<th scope="col">Amount</th>
<th scope="col">Vendor</th>
<th scope="col">Description</t
<th scope="col">Type</th>
<th scope="col">Notes</th>
<th scope="col">Trip</th>
<th scope="col">Last Updated</th>
<th scope="col">Last Updated By</th>
<th scope="col">Done</th>
</tr>
<?php
$get_transactions = "SELECT * FROM transactions order by date ASC LIMIT 10";
$transactions_result_set = mysqli_query($connection, $get_transactions);
$get_types = "SELECT * FROM type";
$type_result_set = mysqli_query($connection, $get_types);
?>
<?php // this section creates the entire table
//the line below creates each record and puts it in a table
?>
<?php
//this opens the tag
$type = "<select>";
//this while statement turns each entry from the database into value
while ($row = mysqli_fetch_assoc($type_r
//this statement appends to the existing variable
$type .= sprintf("<option value='%s'>%s</option>", $row["type_name"], $row["type_name"]);
}
$type .= "</select>";
?>
<?php while ($expenses = mysqli_fetch_assoc($transa
?>
<tr>
<td><?php echo date("F d, Y", strtotime($expenses["date"
<td><?php echo number_format($expenses["a
<td><?php echo $expenses["vendor"];?></td
<td><?php echo $expenses["description"];?
<td><?php echo $type; ?></td>
<td><textarea name="notes" id="notes"></textarea></td
<td nowrap="nowrap">Trip place holder</td>
<td><?php echo date("m/d/Y")?></td>
<td>User Name</td>
<!-- <td><?php// date("F d, Y");?></td>-->
<td><input name="done" type="checkbox" id="done"></td>
</tr>
<?php
}
?>
</table>
<input type="submit">
</form>