Note that there are some explanatory texts on larger screens.

plurals
  1. POReally Easy PHP query. Displaying from separate PHP file
    primarykey
    data
    text
    <p>I'm a PHP n00b. I have this code, however it is on my main page. I assume like jQuery there must be a way to display this without having the actual script on the main document that the users access?</p> <p>Or is there a way I can do this tidier without echo'ing everything?</p> <pre><code> include('talentsearch.php'); while($row = mysqli_fetch_array($result2)) { echo "&lt;div class='talent_result_wrapper' data-experience='" . $row['divTagExp'] . "' data-salary='" . $row['divTagExp'] . "'&gt;"; echo "&lt;ul&gt;"; echo "&lt;li&gt;&lt;strong&gt;Talent ID: &lt;/strong&gt;" . $row['CandidateID'] . "&lt;/li&gt;"; echo "&lt;li&gt;&lt;strong&gt;Resides: &lt;/strong&gt;" . $row['Town'] . "&lt;/li&gt;"; echo "&lt;li&gt;&lt;strong&gt;Salary Required: &lt;/strong&gt;£" . $row['SalaryMin'] . "&lt;/li&gt;"; echo "&lt;li&gt;&lt;strong&gt;Experience: &lt;/strong&gt;" . $row['CandidateExperience'] . " Years &lt;/li&gt;"; echo "&lt;li&gt;&lt;strong&gt;Industy: &lt;/strong&gt;" . $row['PrimarySector'] . "&lt;/li&gt;"; echo "&lt;li&gt;&lt;strong&gt;Specialism: &lt;/strong&gt;" . $row['PrimarySector'] . "&lt;/li&gt;"; echo "&lt;/div&gt;"; } </code></pre> <p>I have tried putting it in a function like this:</p> <pre><code>function getTalent() { } </code></pre> <p>And then calling the function like this</p> <pre><code>&lt;?php include('talentsearch.php'); getTalent() ?&gt; </code></pre> <p>But I get an error whereas I don't if I just run the code normally.</p> <pre><code>Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in </code></pre> <p>So I assume I'm not doing it right.</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