Note that there are some explanatory texts on larger screens.

plurals
  1. POsearch get result empty fields
    primarykey
    data
    text
    <p>i have an question about a command that won't give</p> <p><code>Notice: Undefined index: q in C:\xampp\htdocs\Capstone - Copy\index.php on line 118</code></p> <p>even if the field is empty i have this code for the site that's the only problem where if i don't put a value in my search it will give that error and can i erase the value of get when i reload the site so it will only give the default output that is the whole rows and pictures i'll put a print screen of the site the screen shot is the default view of the site.</p> <pre><code>&gt; &lt;?php &gt; &gt; $searchtext = $_GET['q']; &gt; &gt; &gt; $per_page =5; &gt; $pages_query = mysql_query("SELECT COUNT('PersonID') FROM persons"); &gt; $pages = ceil(mysql_result($pages_query,0) / $per_page); &gt; &gt; $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; &gt; $start = ($page - 1) * $per_page; &gt; &gt; &gt; $query=mysql_query("select * from persons where firstname like &gt; '%$searchtext' or lastname like '%$searchtext' order by date desc &gt; LIMIT $start,$per_page "); while($test = mysql_fetch_array($query)) &gt; { &gt; $id = $test['PersonID']; &gt; &gt; &gt; &gt; echo"&lt;div class = content /&gt;"; &gt; echo"&lt;img height=200 width=200 src='upload/". $test['Image'] ."'/&gt;"; &gt; echo"" .$test['LastName']." "; &gt; echo"". $test['MiddleName']. " "; &gt; echo"". $test['FirstName']. ""; &gt; echo"&lt;right&gt; &lt;a href ='view.php?PersonID=$id'&gt;Edit&lt;/a&gt;&lt;/right&gt;"; &gt; echo"&lt;right&gt; &lt;a href ='del.php?PersonID=$id'&gt;Delete&lt;/a&gt;&lt;/right&gt;"; &gt; echo"&lt;/div&gt;"; &gt; &gt; &gt; &gt; } &gt; if ($pages &gt;=1 &amp;&amp; $page &lt;= $pages) { &gt; for ($x=1; $x&lt;=$pages; $x++) { &gt; echo ($x == $page) ? '&lt;strong&gt;&lt;a href="?page='.$x.'"&gt;'.$x.' &lt;/a&gt;&lt;/strong&gt; ' : '&lt;a &gt; href="?page='.$x.'"&gt;'.$x.' &lt;/a&gt;'; &gt; } &gt; } ?&gt; &gt; &gt; </code></pre> <p><img src="https://i.stack.imgur.com/BlVHg.png" alt="screen shot"> <img src="https://i.stack.imgur.com/nPTPe.png" alt="screenshot2"></p> <p>and here's the sample result that won't give an error because there's a default value</p> <p><img src="https://i.stack.imgur.com/SEk0t.png" alt="screenshot 3"></p>
    singulars
    1. This table or related slice is empty.
    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.
    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