Note that there are some explanatory texts on larger screens.

plurals
  1. POOpening PHP statements
    primarykey
    data
    text
    <p>So I was just wondering if it was considered bad practice to open and close PHP statements, and let me explain what I mean. I know I can make variables at the beginning of my code but I like to group stuff together.I'm not sure if making one big PHP statement with all my variables is better / worse / same as opening and closing PHP statements similar to the example below. </p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;---- HTML STUFF &lt;?php (php stuff where connection to mysql db goes and other variables and errors) ?&gt; &lt;body&gt; &lt;html&gt; &lt;----- HTML stuff &lt;?php (php stuff to call a specific table from DB) ?&gt; &lt;html&gt; &lt;----- HTML stuff &lt;?php (php stuff to call a specific table from DB) ?&gt; &lt;html&gt; &lt;----- HTML stuff &lt;?php (php stuff to call a specific table from DB) ?&gt; &lt;/body&gt; &lt;html&gt; </code></pre> <p>BTW the php variables I'm talking about are specific select statement from the DB.</p> <p>ACTUAL CODE: or should select statements be at beg or sep file?</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td align="left" width="200px"&gt; Cover: Original Total &lt;/td&gt; &lt;td width="200px" align="center"&gt; &lt;?php $original = "SELECT * FROM `comic_db`.`comic_db` WHERE comic_cover=\"original\""; $orig_con = mysqli_query($comic_connect, $original); $orig_total = mysqli_num_rows($orig_con); echo $orig_total; ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="200px" align="left"&gt; Cover: Variants Total &lt;/td&gt; &lt;td width="200px" align="center"&gt; &lt;?php $variants = "SELECT * FROM `comic_db`.`comic_db` WHERE comic_cover=\"variant\""; $variant_con = mysqli_query($comic_connect, $variants); $variant_total = mysqli_num_rows($variant_con); echo $variant_total; ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" width="200px"&gt; Cover: Baby Totals &lt;/td&gt; &lt;td width="200px" align="center"&gt; &lt;?php $baby = "SELECT * FROM `comic_db`.`comic_db` WHERE comic_cover=\"baby\""; $baby_con = mysqli_query($comic_connect, $baby); $baby_total = mysqli_num_rows($baby_con); echo $baby_total; ?&gt; </code></pre>
    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.
 

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