Need help w/ mysql_field_name function in form

Discussion in 'MySQL' started by PGriff, Mar 30, 2011.

  1. #1
    Can anyone please give me some advice on why the code below doesn't show a name value. Everything else works fine (for example, the value field displays) so I think I'm connecting with the database. I'm trying to allow a user to edit a row of their data with POST from a displayed form. The problem might be with this line:

    echo $field_name;


    Here is the code:

    <form action="process.php" method="POST">

    <?

    {$qry = "SELECT username, site, date, FROM home WHERE user_id='$session->user_id' ORDER BY date";
    $res = mysql_query($qry);
    $field_name = mysql_field_name($res, 0);}

    {function mysql_fetch_all($res)

    {while($row=mysql_fetch_array($res))

    {$return[] = $row;}

    return $return;}

    function create_table($dataArr)


    {echo "<form action=\"process.php\" method=\"POST\"><table><tr>";
    for($j = 0; $j < 3; $j++)

    {echo "<td><input type=\"text\" name=\"";

    echo $field_name;

    echo "\" maxlength=\"30\" value=" .$dataArr[$j]. "></td>";}

    echo "<td><input type=\"hidden\" name=\"subedit\" value=\"1\"><input type=\"submit\" value=\"Update\"></td></tr></table></form>";}

    $all = mysql_fetch_all($res);

    echo "<table class='data_table'>";
    echo "<tr><td colspan=\"3\"><h2>Current Profile</h2></td></tr>";
    echo "<tr><small><td>Member&nbsp;</td><td>Site&nbsp;</td><td>Date&nbsp;</td></small></tr>";

    for($i = 0; $i < count($all); $i++)

    {create_table($all[$i]);}

    echo "
    </table>
    </form>";
     
    PGriff, Mar 30, 2011 IP
  2. codeartist

    codeartist Peon

    Messages:
    96
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    can you please clean you your code before you ask for the solution its really messy and difficult to understand the codes '{' used everywhere? sorry
     
    codeartist, Apr 18, 2011 IP