0

Is there a reason why this won't take aciton or submit. I don't get any movement on the browser. Neither of the forms move.

<div data-role="content">
    <?php
        echo "<table width=\"500\" border=\"1\" cellpadding=\"4\">";
            while($row = mysql_fetch_array($showEmployees))
            { 
            echo "
                <div data-role=\"collapsible\" data-mini=\"true\" data-content-theme=\"c\">
                <h3>{$row['employee']}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$row['phone']}</h3>
                <p>
                    <form action='admin.php' method='post' accept-charset='UTF-8' id='editemployee' >
                    <div data-role=\"fieldcontain\">
                        <input type='hidden' name='employeeid' id='employeeid' value='{$row['id']}'/>
                        <label for='employee' >Name:</label>
                        <input type='text' name='employee' id='employee' value='{$row['employee']}'/><br/>
                        <label for='phone' >Phone#:</label>
                        <input type='text' name='phone' id='phone' value='{$row['phone']}'/><br />
                        <label for='management' >Management: {$row['management']}</label>
                        <select name=\"management\" id=\"management\" data-role=\"none\">
                        <option value=\"0\">No</option>
                        <option value=\"1\">Yes</option>
                        </select><br />
                        <label for='active' >Active: {$row['active']}</label>
                        <select name=\"active\" id=\"active\" data-role=\"none\">
                        <option value=\"1\">Yes</option>
                        <option value=\"0\">No</option>
                        </select><br />

                        <input type='submit' name=\"Submit\" value='Submit {$row['employee']}' />
                    </div>
                    </form>
                        <form action='admin.php' method='post' accept-charset='UTF-8'>
                        <div data-role=\"fieldcontain\">
                        <label for='deleteThisEmployee' ><h1>Delete:</h1></label>
                        <input type='hidden' name='deleteThisEmployee' id='deleteThisEmployee' value='{$row['id']}'/>
                        </div>
                        <input type=\"submit\" data-theme=\"a\" name=\"deleteEmployee\" id=\"deleteEmployee\" value=\"{$row['employee']}\">
                    </form>
                </p>
                </div>
            ";
        };
        echo "</table>";
    ?>
</div><!-- /content -->

Edited by wolfgangcs: *Changed a portion of the code to shorten example

8
Contributors
11
Replies
67
Views
4 Years
Discussion Span
Last Post by masterjiraya
Featured Replies
  • 1

    I don't understand the fuss about the curly brackets, it is allowed and a correct way to include a variable in a double quoted string or heredoc. Read More

0

Yes there are many reasons , the first is that you mix the view with the logic ,

the second one is that you are using mysql_fetch_array that is deprecated and really bad practice many-many years now ,

the third one is that you use brackets as if is something on them e.g. {$row['employee']} of course that is {value} ,

the fourth one and the most important is that you generate in html really a lot of bunch of forms , in each while you generate html for 2 (two) forms , the number of forms that you generate is the number of rows multiplied by two , so which one of all of them are you submitting ?

0

Thank you so much for the heads up. Let me see where follow.

....Yikes

  1. "mix the view w/ the logic"...I'm not following. I'm sorry.
  2. What is up to date besides: mysql_fetch_array()

    1. What should {$row['employee']} be......{?}
  3. Got it! No more than one form in one while?

Link me to death if need be. I thank you for the insight. It's good to get a update on the old stuff I was reading.

1

the second one is that you are using mysql_fetch_array that is deprecated and really bad practice many-many years now ,

Bit misleading there i fear, not only is mysql still in use and not deprecated AFAIK, it's not likely to be either, although it's recommended to use PDO with mysql or procedural mysqli.
I'm sure I will be corrected if I am wrong.

Votes + Comments
You're correct on what he should be using to connect to MySQL
1

I don't understand the fuss about the curly brackets, it is allowed and a correct way to include a variable in a double quoted string or heredoc.

Edited by pritaeas

Votes + Comments
I was wondering this too.
0

I don't understand the fuss about the curly brackets, it is allowed and a correct way to include a variable in a double quoted string or heredoc.

I didn't even read that far into it. I agree, there is nothing wrong with using {}.

What does the output of this look like in a browser? Maybe the while loop is creating a problem or possible something else outside of the code shown here.

0

Every form has the same id
change to
<form action='admin.php' method='post' accept-charset='UTF-8' id='editemployee{$row['id']}' >

do something simular for the id of the input fields

0

quote from php manual http://php.net/manual/en/function.mysql-fetch-array.php stating deprecation of mysql_fetch_array()

Warning
This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:

mysqli_fetch_array()
PDOStatement::fetch()

As per the doubt.I can see that page is redirected to admin.php on form submit.I am not sure about the condition.I am assuming that you are getting data from database.

0

pls repost your new edited code of this problem I think I can see where the error is. Lemme see if your edited code stuff is still the same manner. All the variables are enclosed on echo function. you forgot something to do to retrieve it properly. (.)<--this is the clue

Edited by masterjiraya

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.