Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

html select inside table

$
0
0

i have a table that is built off a select statement pulling records from mysql. the table has the following fields.

 

id,transaction_date,description,check_number,amount,transaction_category

 

I import a csv that has all the info but the transaction_category. I want to have a select box that is created from a separate query in each row of the html table. The idea is i can quickly assign a category to a transaction using the drop down and save my changes. I am stuck on to areas.

 

1. The select box is off by one column in my table

2. Only the first select box has data.

 

I get a correct looking table with all the data and the select dropdown on every row.

echo '<table border="1" cellpadding="5" cellspacing="5" class="db-table">';
		echo '<tr><th>ID</th><th>Date</th><th>Description</th><th>Check Number</th><th>Amount<th>Category</th></tr>';
		while($row = $sql_select->fetch())
                {
			echo '<tr>';
			foreach($row as $key=>$value)
                        {
				echo '<td>',$value,'</td>';
                                
                         
			}
                        
                               echo "<td>";
                                echo "<select name=\"category\">";
                            while($row2 = mysql_fetch_array($results_cate)) 
                            {        
                                echo "<option value='".$row2['category']."'>".$row2['category']."</option>";
                                
                            }
                            echo "</select>";
                            echo "<td>";
                        
                        echo "</tr>";
			//echo '</tr>';
		}
		echo '</table><br />';

Viewing all articles
Browse latest Browse all 13200

Trending Articles