problem with fetch rows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saeedeh
    New Member
    • Aug 2006
    • 11

    problem with fetch rows

    hi to all
    i have some problem with fetching my form enteries. the problem is when i post some enteries through a form to a databse called 'applicant' and try to fetch and print it nothing appears.it seems that nothing has passed to the databse. but i think i`ve written the code correctly.can you please tell me what you think about my problem.there`s sth i should note:some of my text fields in the form are disabled and if the user checks sth they will be abled else no.
    i`m getting these enteries in persian format(not in english)...shou ld it be some problem with the encoding?
    here`s the databse code(and thanks a lot)

    <?php
    if(isset($_POST['submit']))
    {
    $national=$_POS T['Nationalnum'];
    $account=$_POST['Accountnum'];
    $wifename=$_POS T['Wifename'];
    $surname=$_POST['Surname'];
    $parent=$_POST['Parentname'];

    }

    $db = mysql_connect(" localhost","adm inistrator", "")or die ("Could not connect to localhost");
    mysql_select_db ("applicant" , $db)or die ("Could not find the database");
    $table_name ="personalinfo" ;
    $query="INSERT INTO personalinfo ( nationalnum , accountnum)
    VALUES ('$national', '$account')";
    mysql_query($qu ery) or die (mysql_error()) ;
    $query = "select * from $table_name";
    $result = mysql_query($qu ery);
    $num_rows=mysql _num_rows($resu lt);
    $num_fields = mysql_num_field s($result);
    //create table header
    echo "<table border = 1>";
    echo "<tr>";
    for ($i=0; $i<$num_fields; $i++)
    {
    echo "<th>";
    echo mysql_field_nam e ($result, $i);
    echo "</th>";
    }
    echo "</tr>";
    //end table header
    //create table body
    echo "<tr>";
    for ($i=0; $i<$num_fields; $i++)
    {
    echo "<td valign = top>";
    echo mysql_field_typ e ($result, $i) . "<br> \n";
    echo "(" . mysql_field_len ($result, $i) . ")<br> \n";
    echo mysql_field_fla gs ($result, $i) . "<br> \n";
    echo "</td>";
    }
    echo "</tr>";
    //*************** ****enteries*** ***************
    for($j=0; $j<$num_rows; $j++)
    {
    echo "<tr>";
    while ($row = mysql_fetch_row ($result))
    {
    ///echo "$row['$nationalnum'] $row['$accountnum']<br />";
    echo "<th>$row[0]</th> <th>$row[1]</th><br/>";
    }
    echo "</tr>";

    }
    echo "</table>";
    mysql_close($db );
    ?>
  • bevort
    New Member
    • Jul 2006
    • 53

    #2
    Try to use mysql_fetsh_arr ay instead

    Comment

    • saeedeh
      New Member
      • Aug 2006
      • 11

      #3
      thanx a lot for your reply
      i think i have made a mistake somewhere else

      Comment

      • bevort
        New Member
        • Jul 2006
        • 53

        #4
        Hello glad you solved it but?

        I may help one of us if you describe what the problem was

        regards Vincent

        Comment

        • saeedeh
          New Member
          • Aug 2006
          • 11

          #5
          Originally posted by bevort
          Hello glad you solved it but?

          I may help one of us if you describe what the problem was

          regards Vincent
          hi
          the problem was that i included "if(isset($_POS T['submit']))" at the top of the page to get the previous entreies but when i omitted that part the code started to work correctly.i don`t know what was the problem with submit button.however its name was really 'submit' ;
          thanx again

          Comment

          • rkagrawal
            New Member
            • Aug 2006
            • 13

            #6
            There are often problems related to submit buttons and posting data back to site. However most of them are due to some minute mistake but there are some which arise as a result of violating a rule in PHP.

            If you get stuck anywhere with PHP feel free to PM Me , Email me or just IM me and i will try to help you out the best i can.

            Rahul Agrawal
            Developer
            Web2003 Corporation
            www.web2003corp .com

            Comment

            • saeedeh
              New Member
              • Aug 2006
              • 11

              #7
              Originally posted by rkagrawal
              There are often problems related to submit buttons and posting data back to site. However most of them are due to some minute mistake but there are some which arise as a result of violating a rule in PHP.

              If you get stuck anywhere with PHP feel free to PM Me , Email me or just IM me and i will try to help you out the best i can.

              Rahul Agrawal
              Developer
              Web2003 Corporation
              www.web2003corp .com

              THANX A LOT i`ll gratefully do that

              Comment

              Working...