Note that there are some explanatory texts on larger screens.

plurals
  1. POChoosing where to echo statement
    primarykey
    data
    text
    <p>I was rewriting my old ugly code into something more practical as I will be adding allot of features that will interlink, so a clean code is a must now.</p> <p>I was doing everything in functions so I had 18 little forms in a page and 18 little functions echoing in that same page for example.</p> <pre><code>echo getstatement($username); echo $getname($username); echo $getemail($username); echo $gethistory($user); </code></pre> <p>These are all forms not something you see when you open the page, so I would do</p> <pre><code>if (isset($_POST['username']) { $username = $_POST['username']; } </code></pre> <p>Anyways I changed the code to print out where I want it like before by using simply one variable called message that I assign when each form is submited.</p> <p>so now it's </p> <p>echo $message;</p> <p>Great, all of them were fine except the ones that were based of while loops. I check history using a while loop and then echo the mysql rows using $row['column']; , alright now it echos at the top of the page in the corner. </p> <p>Can I simply save the while loop as a variable and then echo the whole loop when it's done?</p> <p>EG code:</p> <pre><code>while ($row = $query-&gt; fetch(PDO::FETCH_ASSOC)) { echo "&lt;tr&gt;&lt;td&gt;"; echo $row['name']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['invoiceid']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['description']; echo "&lt;/td&gt;&lt;td&gt;"; echo $row['time']; echo "&lt;/td&gt;&lt;/tr&gt;"; } </code></pre> <p>This used to work well when it was a function but now it's not as good. So how am I supposed to save this in a variable that I can echo where I want. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload