I'm a moderate level PHP developer and I'm trying to move to asp.net for a project but finding this a very difficult and alien experience. The hole ASP.net world is so different from the traditional PHP/mysql way of doings things. My head hurts.

What I want to do is generate a table dynamically in ASP.net by running an sql query and then loading the results into an array then iterate through the array and extract the columns I want and store then as variables that can be used to generate the table dynamically. this seems really simple and it should be but I'm getting nowhere with this in asp.net, using c# in a visual studio environment. I don't want to use grid views or anything like that, Id rather try and to it entirely programaticaly.

The table is sort of like the front page of a forum and I have it working in a ruff php script as follows. Can anybody show me how to recreate this in asp.net and C#?

//connect to database
@mysql_select_db($database)or die("Unable to connect to the database");//error trapping
$query="SELECT * FROM category";



echo'<table class="forumMain" id="category" cellspacing="0" cellpadding="1" ><tr>';
    while ($i < $num) {
        $query2="SELECT * FROM list WHERE category_id =$id";
               echo '<th id="forumHeading1">'.$catname.'</th>';
               echo '<th id="forumHeading2">Threads</th>';
               echo'<th id="forumHeading3">Posts</th>';
               echo'<th id="forumHeading4">Last Post</th>';
     while  ($rows = mysql_fetch_array($result2)){
        $mbname = $rows["mb_name"];    
                echo'<td class="forumRow">'.$mbname.'</td>';
                echo'<td class="forumRow">&nbsp;</td>';
                echo'<td class="forumRow" >&nbsp;</td>';
                echo'<td class="forumRow">&nbsp;</td>';

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.