| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: May 2005 Location: Ontario Canada
Posts: 3,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Making a table...with multiple fields Hey I am getting data from a form ..[allowing as many fields ] and then im using that data to make a table...but i cant figure out how to make that table.. should i make the table first...then go through each input and make fields [but then it would use 2 many queries] or is there another way of doing it?
__________________ |
| |
| | #2 (permalink) |
| NamePros Member Join Date: Aug 2006 Location: amsterdam
Posts: 93
![]() ![]() ![]() | I'll might be able to answer your question if you provide the form code...
__________________ Directory Bids | ArcadeCharts.com | Play Arcade Games CasinoPremiums.com | DrmRemover.com | InsuranceBasic.com | Pedicure.cc | 32-bit.com | BearDolls.com |
| |
| | #3 (permalink) |
| NamePros Regular Join Date: Oct 2005 Location: Portugal
Posts: 800
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | what this code do? simple, it gets the all the content of the table bug and display it. Code: <?php
// starts the table
<table class="style19" cellspacing="0" cellpadding="0">
//query the database
$query = "SELECT * FROM bug ORDER BY id_bug DESC";
$result = mysql_query($query) or die(mysql_error());
// starts a cycle and will only stop when there is no more results from the query
while($row = mysql_fetch_array($result)){
$bug_list1 .="
<tr>
// $row['name of your field'] if you have 20 fields then add more lines
<td class='style40'>".$row['id_bug']."</td>
<td class='style40'>".$row['topico']."</td>
<td class='style40'>".$row['username']."</td>
<td class='style40'>".$row['assigned']."</td>
<td class='style40'>".$row['status']."</td>
</tr>
";
}
echo $bug_list1;
?>
</table> if you want to change the colors from one line to the other you can do this: Code: <table class="style19" cellspacing="0" cellpadding="0">
<?php
$query = "SELECT * FROM bug ORDER BY id_bug DESC";
$result = mysql_query($query) or die(mysql_error());
$var = "Y";
while($row = mysql_fetch_array($result)){
if ($var=="Y"){
$bug_list1 .="
<tr>
<td class='style30'>".$row['id_bug']."</td>
<td class='style30'>".$row['topico']."</td>
<td class='style30'>".$row['username']."</td>
<td class='style30'>".$row['assigned']."</td>
<td class='style30'>".$row['status']."</td>
</tr>
";
}
if ($var=="N"){
$bug_list1 .="
<tr>
<td class='style20'>".$row['id_bug']."</td>
<td class='style20'>".$row['topico']."</td>
<td class='style20'>".$row['username']."</td>
<td class='style20'>".$row['assigned']."</td>
<td class='style20'>".$row['status']."</td>
</tr>
";
}
if ($var=="N"){
$var="Y";
}else $var="N";
}
echo $bug_list1;
?>
</table> ????: NamePros.com http://www.namepros.com/programming/326447-making-a-table-with-multiple-fields.html hope it helps.
__________________ Joćo Fernandes Silva |
| |
| | THREAD STARTER #4 (permalink) |
| Senior Member Join Date: May 2005 Location: Ontario Canada
Posts: 3,088
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | hm no u guys are getting the wrong idea...I am talking about a MYSQL database table here is my code: PHP Code:
__________________ |
| |
| | #5 (permalink) |
| NamePros Member Join Date: Aug 2006 Location: amsterdam
Posts: 93
![]() ![]() ![]() | I'm not sure if this helps but: I think you could create a table first throuh phpadmin (or something similiar) with the fields: id [auto increment], name, type, lenght, null, unique. Also make the input names arrays. Example: change name$a => name[$a], type$a => type[$a], etc... So when a user submits the form, you just have to loop through the array and create the INSERT query. Ones the query is created, you just have to execute it. That way you only have to execute one query. Ms Grace
__________________ Directory Bids | ArcadeCharts.com | Play Arcade Games CasinoPremiums.com | DrmRemover.com | InsuranceBasic.com | Pedicure.cc | 32-bit.com | BearDolls.com |
| |
| | #6 (permalink) | ||||
| DNOA Certified Seller ![]() Join Date: Apr 2005 Location: Arizona
Posts: 3,680
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code: ![]() Hope this helps, Jorge
__________________ Nombrex.com | ||||
| |