| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Senior Member | 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 | 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 | 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>
hope it helps.
__________________ Joćo Fernandes Silva Selling : 19P.ORG - ARCADEHITS.ORG - AZIAN.NET - COREFANS.COM - CTUTORIALS.NET - DEDISEEK.COM - HITCHECK.COM - HOST15.COM - HOSTCUSTOMER.COM - LARGETIPS.COM - SCRIPTCANDY.COM - VISUALBOOK.NET - VOXVPS.COM / .NET - WALLPAPERSARENA.COM |
| |
| | #4 (permalink) |
| Senior Member | 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 | 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 | Quote:
PHP Code: ![]() Hope this helps, Jorge
__________________ <--- baby Rogan says: sorry for spelling/punctuation mistakes, daddy's feeding me | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |