Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: looping in the table

  1. #11
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    when we click any form it will direct to the same page..(say form.php, hich i forgot to mention)

    Code:
    <html> 
    <head><title>Your Page Title</title></head> 
    <body> 
    <?php
    session_start();
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = 'sister';   
    $dbname = 'login';
    echo "hello";
    // make a connection to mysql here
    $conn = mysql_connect ($dbhost, $dbuser, $dbpass);
    if(!$conn)
    {
    die('could not connect: ' . mysql_error());
    }
    else
    echo "<BR>connected";
    //select database to use
    $conn = mysql_select_db ($dbname);
    echo "<BR>connected to db" ;
    
    $result = mysql_query("SELECT taxtype.taxtypeid,taxname,taxdesc,group_concat(formno),group_concat(formno2),actid,taxtype.status as formnum  FROM taxtype,taxform where taxtype.taxtypeid=taxform.taxtypeid group by taxtypeid")or die(mysql_error());
    $num_rows = mysql_num_rows($result);
    echo "<BR>" . $num_rows;
    print "<table width=500 border=1>\n";
      print "<tr>\n";
                    print "\t<td><font face=arial size=4/>S.No.</font></td>\n";  
                    print "\t<td><font face=arial size=4/>Tax Name</font></td\n";
                     print "\t<td><font face=arial size=4/>Tax Description</font></td\n"; 
                    print "\t<td><font face=arial size=4/>Return-cum-challan(TIN/RC No. mandatory):</font></td\n"; 
                    print "\t<td><font face=arial size=4/>Challan No (TIN/RC No. not mandatory):</font></td\n"; 
                   print "\t<td><font face=arial size=4/>Act ID:</font></td\n"; 
                    print "\t<td><font face=arial size=4/>Status</font></td\n"; 
          print "</tr>\n"; 
    while($row = mysql_fetch_row($result))
    {
         //echo "<BR>" . $row[0] . "   " . $row[1] . "   " . $row[2] ;
         print "<tr>\n";
                    
                    print "\t<td><font face=arial size=2/>$row[0]</font></td>\n"; 
                    print "\t<td><font face=arial size=2/>$row[1]</font></td>\n";  
                    print "\t<td><font face=arial size=2/>$row[2]</font></td>\n"; 
                   $forms=explode(",",$row[3]);
                   $size= count($forms);
                    echo "<BR>" . $size;
                                   
                   print "\t<td>";
    for ($i=0;$i<$size;$i++)
                       {
                           print "\t<font face=arial size=2/> <a href=\"http://localhost/form.php\" target=\"_blank\">$forms[$i]</a> </font>\n";
                       }
    print "</td>";
    $forms1=explode(",",$row[4]);
                   $size= count($forms1);
                    echo "<BR>" . $size;
                                   
                   print "\t<td>";
    for ($i=0;$i<$size;$i++)
                       {
                          print "\t<font face=arial size=2/> <a href=\"http://localhost/.php\" target=\"_blank\">$forms1[$i]</a> </font>\n";
                        }
    print "</td>";
                    print "\t<td><font face=arial size=2/>$row[5]</font></td>\n"; 
                    print "\t<td><font face=arial size=2/>$row[6]</font></td>\n"; 
           
         print "</tr>\n"; 
     }
          print "</table>\n";  
    
    ?>
    
    ADD  A NEW TAX
    <a href="http://localhost/newtax.php"  target="_blank">NEW TAX</a>
    </body> 
    </html>
    now,what i want is..when i click on any of the links(which would direct me to same page login.php) ,i want to display the value in the link on the new page i.e on form.php....as i mentioned in my previous post

    i tried using session variable in the page where the above code is present ..
    but how do i store the value of the link i have clicked ..?


    and moreover i didnt understnd the wrapping concept which u have suggested.

  2. #12
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    I have a little problem , i have a table in my database called "typetax" in which one of the column is "taxname" which consist of names of different taxes.

    now i want to connect to the database using php(which i know how to do) and then i would like to diaplay all the taxes using a drop down list.
    i am getting confused how to use html and php together ..

    Code:
    <html> 
    <head> 
    <title>DATAENTRER PAGE</title> 
    </head> 
    <body> 
    <?php
    session_start();
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = 'sister';   
    $dbname = 'login';
    echo "hello";
    // make a connection to mysql here
    $conn = mysql_connect ($dbhost, $dbuser, $dbpass);
    if(!$conn)
    {
    die('could not connect: ' . mysql_error());
    }
    else
    echo "<BR>connected";
    //select database to use
    $conn = mysql_select_db ($dbname);
    echo "<BR>connected to db" ;
    
    $result = mysql_query("SELECT taxname  FROM taxtype")or die(mysql_error());
    $num_rows = mysql_num_rows($result);
    echo "<BR>" . $num_rows;
    ?>
    </body>
    </html>
    but now how do i display all the taxname's on the page in a drop down format using php?
    its really urgent so please could u help me in this

  3. #13
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Would you please not make your entire messages bold anymore? It's senseless, and kind of annoying.

    The session veriable is probably not the best way. To get the link's value into the session, you'd need JavaScript, but that would be obtrusive which is bad. (obtrusive = inaccessible to the user without JS available or enabled.)

    I was suggesting that each link have the name of the form in a GET variable - and that's just a second use of the form's name that we already have. So...
    Code:
     print "\t<td>";
    for ($i=0;$i<$size;$i++)
                       {
                           print "\t<font face=arial size=1/> <a href=\"http://localhost/form.php?form=$forms[$i]\" target=\"_blank\">$forms[$i]</a>, </font>\n";
                       }
    print "</td>";
    For your last post, use a while($row = mysql_fetch_array($result)) loop inside of a select element. I recently did something similar in this script. In my case, the while loop isn't actually in the select but the same idea is used.
    Last edited by Jesdisciple; 07-05-2009 at 09:28 PM.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  4. The Following User Says Thank You to Jesdisciple For This Useful Post:

    padmaharika (07-06-2009)

  5. #14
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    How can i print the "link text" of a hyperlink in html in the next page (to which its it directed to)

    for eg:
    <a href="http://localhost/form.php" target="_blank">566</a>

    when i click the link 566 ..i will be directed to form.php.Now i would like to display the number 566 (i.e by passing it from prev page to this page)

  6. #15
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    well sir, i m sorry that u have alrdy given me the solution for this , but i have another doubt here , how do i separate two values if i need to pass more than one value

    Code:
    for ($i=0;$i<$size;$i++)
                       {
                           print "\t<font face=arial size=2/> <a href=\"http://localhost/form.php?tname=$row[1] ,form=$forms[$i]\" target=\"_blank\">$forms[$i]</a> </font>\n";
                       }
    print "</td>";
    by using a comma ,isnt helping me ..so plz could u tell me how to go about it

  7. #16
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    To access your values, use $_GET['form'] and $_GET['tname']. I prefer to rename them to something more readable and typable, like $form and $tname. However, to use a new name to validate that a value was actually passed you must assign by reference:
    Code:
    $form =& $_GET['form'];
    if(isset($form)){
        ...
    }
    The separator for GET annd POST values is the ampersand (&). If you ever write a cookie (small data file that the browser stores on the user's computer), you'll need to use a semicolon (;) instead. EDIT: And don't include any spaces around either separator.
    Last edited by Jesdisciple; 07-06-2009 at 05:41 PM.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  8. The Following User Says Thank You to Jesdisciple For This Useful Post:

    padmaharika (07-07-2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •