I am designing a Plugin that search through mysql database and display the result.
this is the code for my "content.php"
<p>
<div style="text-align:center">
<form action="mod/openProgram_widget/search.php" method="post">
Search: <input type="text" name="term" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
</div>
</p>
And it points to "search.php" which is made of the following.
<?php
mysql_connect ("localhost", "root","") or die (mysql_error());
mysql_select_db ("study");
$term = $_POST['term'];
$sql = mysql_query("select * from testtable where FName like '%$term%'");
while ($row = mysql_fetch_array($sql)){
echo 'ID: '.$row['ID'];
echo '<br/> Name of School: '.$row['Name of School'];
echo '<br/> Study Name: '.$row['Study Name'];
echo '<br/> Description: '.$row['Description'];
echo '<br/> Contact: '.$row['Contact'];
echo '<br/><br/>';
}
But when i click search, it opens an empty new browser window, and not the search results.
Please i need help ?
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Team Webgalli@webgalli
Team Webgalli - 0 likes
- To create the search for put the html for search input inside views/yourplugin/forms/search.php
- Create a corresponding action file
Also you are directly making the query with our doing any filtering on input. This is a big security issue. Have alook at any of the bundled plugin and see how the form and actions are created in elgg If you can explain your requirements, community can help you with proper API
- ax9g9n@imanuelgh
ax9g9n - 0 likes
- Team Webgalli@webgalli
Team Webgalli - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- ax9g9n@imanuelgh
ax9g9n - 0 likes
- ax9g9n@imanuelgh
ax9g9n - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- ax9g9n@imanuelgh
ax9g9n - 0 likes
You must log in to post replies.This is not the proper way of doing Elgg coding
Thank you for the quick response.
Please, i am newbie to elgg, but i am prepared to become a Pro. I am designing a An Education and Training Program for Information Service Plugin for my University,We will manually Populate its database, When users add the plugin, they can search through and display a result;
The Database has the following:
Programme ID(key)
Programme Name:
Programme Type:
Duration:
Start Date:
End Date:
Contact Person:
Url:
A Search that will "query" it, and display the result;
I hope members understand my situation now and i ll be glad to get the needed inputs.
You can achieve this without creating any new tables for this. Just creat it as an Elgg entity, and assign the values as metadatas. See the documentation at http://docs.elgg.org and read the DB structure and elgg data model. Have a look at http://docs.elgg.org/wiki/Tutorials/Blog
To fetch the data you can then use the elgg_get_entities_from_metadata() function
If you are ready to spend a few bucks and willing to read and learn about Elgg, get the book on Elgg from http://www.amazon.com/Elgg-Social-Networking-Cash-Costello/dp/1849511306
generally - the comments about the 'Elgg way' is mostly on the mark ;)
If you want to spend tome to learn how Elgg is designed, the API functioning and all those other nice things about Elgg -- be ready for some initial hard work. you'll get there.. That WIki link above is a good place to start. Like anything else - it will appear too difficult at first.. but more effort = less pain..;;P;X
re: your PHP code that displays that 'empty window' -->
try this ==>
$sql=mysql_query(" select * from testtable where FName like '%$term%' ");
echo"<h2>TERM=($term)</h2><h2>SQL=($sql)</h2>";//:DC: dbg
exit();//:DC: dbg
while($row=mysql_fetch_array($sql)){
. . .
you'll see what if wrong with your code soon ;-oO
Thank you, i just bought the book from amazon and i am still reading, but i need to finish this, i am behind shedule.
@DhrupDeScoop , I followed your reply ,thank you,i am now getting this error :
TERM=(KNUST)
SQL=()
the name KNUST is the search query i entered, to search in the database. But it still opens a new browser tab.
Please, find the url, for my plugin beloww
https://www.box.com/s/fb5188c59404f2d6bc10
I would be glad,if i can get something similar, so that i can make modifications and develop it quickly. To let members know how serious i am to learn elgg and help me out, i am at chapter four(Sharing Content) of the book i bought 45 minutes ago,
$term = $_POST['term'];
$sqlX = " select * from testtable where FName like '%$term%' ";
echo"<h2>TERM=($term)</h2><h2>SQL=($sqlX)</h2>";//:DC: dbg
$sql = mysql_query($sqlX);
. . .
@ DhrupDeScoop, now i am getting server error. Can you please add some notes ?