Note that there are some explanatory texts on larger screens.

plurals
  1. POSearch and display results from SQL database
    primarykey
    data
    text
    <p>I have an MySQL database and I need to search for either the transaction number (and it shows me my name, email and item_name) or search for my email address AND name AND date of purchase which will then give me my transaction number and item_name - I don't want anything to come up unless email, name and date of purchase are all correct.</p> <p>Fields in my database are:</p> <pre><code>iname iemail itransaction_id item_name </code></pre> <p>Could someone please help.... this is what i currently have....</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Search&lt;/title&gt; &lt;/head&gt; &lt;body bgcolor=#ffffff&gt; &lt;h2&gt;Search&lt;/h2&gt; &lt;form name="search" method="post" action="findme.php"&gt; Seach for: &lt;input type="text" name="find" /&gt; &lt;input type="submit" name="search" value="Search" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>saved as findme.html</p> <p>next:</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;Searching for a student...&lt;/title&gt; &lt;/head&gt; &lt;body bgcolor=#ffffff&gt; &lt;?php echo "&lt;h2&gt;Search Results:&lt;/h2&gt;&lt;p&gt;"; //If they did not enter a search term we give them an error if ($find == "") { echo "&lt;p&gt;You forgot to enter a search term!!!"; exit; } // Otherwise we connect to our Database mysql_connect("xxxx.com", "xxxx", "xxxxpw") or die(mysql_error()); mysql_select_db("xxxx") or die(mysql_error()); // We perform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $iname = mysql_query("SELECT * FROM ibn_table WHERE upper($field) LIKE'%$find%'"); //And we display the results while($result = mysql_fetch_array( $iname )) { echo $result['firstname']; echo " "; echo $result['lastname']; echo "&lt;br&gt;"; echo $result['idnumber']; echo "&lt;br&gt;"; echo "&lt;br&gt;"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($iname); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query...&lt;br&gt;&lt;br&gt;"; } //And we remind them what they searched for echo "&lt;b&gt;Searched For:&lt;/b&gt; " .$find; //} ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Which is saved as findme.php</p> <p>This is the error im currently getting:</p> <p>Search Results:</p> <p>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hermes/bosweb25a/b409/ipg.bexgroupcouk/silverliningnetworks/Database/findme.php on line 31</p> <p>Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hermes/bosweb25a/b409/ipg.bexgroupcouk/silverliningnetworks/Database/findme.php on line 43 Sorry, but we can not find an entry to match your query...</p> <p>Searched For: CARYS</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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