Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Show results, conditional based on link
    text
    copied!<p>Looking for some help with the code below. I think there may be an issue with the way I've organized the php call and function calls. I'm a beginner and am trying to allow users to display results from different tables, depending on what link they click. </p> <p>I get this error: </p> <p>Parse error: syntax error, unexpected '{' in /home/content/c/e/l/celebrything/html/wp-content/themes/celebrything/sidebar.php on line 16</p> <p>Any help in correcting the issue here would be amazing. Here's the code:</p> <pre><code>&lt;div id="sidebar"&gt; &lt;div class="post"&gt; &lt;h2&gt; &lt;font color="#333333"&gt;Most Popular Celebrities&lt;/font&gt;&lt;br&gt; &lt;font color="#333333"&gt;in last 24 hours&lt;/font&gt; &lt;br&gt; &lt;br&gt; &lt;a href="page.php?table=today"&gt;Today&lt;/a&gt; &lt;a href="page.php?table=week"&gt;Week&lt;/a&gt; &lt;a href="page.php?table=month"&gt;Month&lt;/a&gt; &lt;?php if (!in_array($table, array('today', 'week', 'month')) { return false; } global $wpdb; $result = $wpdb-&gt;get_results('SELECT name, count FROM wp_celebcount_' . $table); foreach($result as $row) { echo '&lt;a href="http://www.celebrything.com/?s=' . urlencode($row-&gt;name) . '&amp;search=Search"&gt;' . $row-&gt;name . '&lt;/a&gt; - ' . $row-&gt;count . ' Posts&lt;br/&gt;'; } } ?&gt; showTable($_GET['table']); &lt;/h2&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; </code></pre> <p><strong>UPDATED CODE</strong>----------------</p> <pre><code>&lt;div id="sidebar"&gt; &lt;div class="post"&gt; &lt;h2&gt; &lt;font color="#333333"&gt;Most Popular Celebrities&lt;/font&gt;&lt;br&gt; &lt;font color="#333333"&gt;in last 24 hours&lt;/font&gt; &lt;br&gt; &lt;br&gt; &lt;a href="page.php?table=today"&gt;Today&lt;/a&gt; &lt;a href="page.php?table=week"&gt;Week&lt;/a&gt; &lt;a href="page.php?table=month"&gt;Month&lt;/a&gt; &lt;?php if (!in_array($table, array('today', 'week', 'month'))) { return false; } global $wpdb; $result = $wpdb-&gt;get_results('SELECT name, count FROM wp_celebcount_' . $table); foreach($result as $row) { echo '&lt;a href="http://www.celebrything.com/?s=' . urlencode($row-&gt;name) . '&amp;search=Search"&gt;' . $row-&gt;name . '&lt;/a&gt; - ' . $row-&gt;count . ' Posts&lt;br/&gt;'; } if (!empty($_GET['table'])) { showTable($_GET['table']); } else { showTable('today'); } ?&gt; &lt;/h2&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; </code></pre>
 

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