Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get a php table to print a range of input values but, ignore the ones that are not filled in?
    primarykey
    data
    text
    <p>I have made a form for a company website that the user will populate with personal info. I want to use php to handle these values and then render them as a table that can be printed. I have done this before but only for forms where everything is filled in. I want to make this one to where if the user decides to leave a field blank then you will not see it in the php rendered page. I will post a small example below for reference to help with my issue, as of now I have no idea where to start.</p> <p>Example form...</p> <pre><code>&lt;form action="post"&gt; &lt;p&gt;&lt;input type="text" id="name" name="name"&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="text" id="phone" name="phone"&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="text" id="job" name="job"&gt;&lt;/p&gt; &lt;/form&gt; </code></pre> <p>In this example form I am gathering name, phone number, and occupation. At the bottom I would have a button to submit the info. A php doc will then handle the values and render them in a table set up like this...(assume I $_POST the variables above this table.)</p> <pre><code>'&lt;table&gt; &lt;tr&gt; &lt;td&gt;Name:' .$name. '&lt;/td&gt; &lt;td&gt;Phone:' .$phone. '&lt;/td&gt; &lt;td&gt;Job:' .$job. '&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;' </code></pre> <p>This works fine however if the customer decides NOT to give there phone number it looks like this...</p> <p>Name: Alex</p> <p>Phone: </p> <p>Job: Fireman</p> <p>What I need to do is make it to where if they DO fill out the phone number it will show it however if they do not I need it to look like this...</p> <p>Name: Alex</p> <p>Job: Fireman</p> <p>My actual form is very long however I thought this example would be enough for someone to help me get started, thanks in advance for your feedback.</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.
 

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