Forum Moderators: coopster
The database will hold a variety of information on a perticular topic Cars for example I would like to be able to stroe images and text in the database and then have a serch box which will return the results from the database and display them on the page
any suggestions
thanks
M
articles id, catagory, title, body, rate
I have built a simple form which I will use to update the database with new articles
I have 3 text boxes catagory, title and body
I would like to validate the form before its submitted to check all the form fields have been compleated
it then posts the data to a simple php form that passes the data to the DB
the form works fine but after submitting the form I get now notice back saying update was ok
if possible on the new article form I would like to be able to display a list of all the articles on the database and then after a new record has been created return the user to the form where the new entry will apear
anyone have any sugestions or links I could use
thanks
M
There's a thread from our library that will help you get started. Once you get something to start with we can go from there if you need additional help. :)
I will sort out the main search later its not that dificult just a case of running a full text search accross the tb and then displaying the results :-)
I have created a dynamic list box I would like to use it to run some quiries
<?php
mysql_select_db($database,$connect) or die ("error cannot connect");
$result = mysql_query($database,$connect);
$query="SELECT name,id FROM category";
$result = mysql_query ($query);
echo "<select name=name value=''>Catagory Search</option>";
// printing the list box select command
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[id]>$nt[name]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>
say the list box selected is asp.net I want to be able to run a query to display the selected catagory
somthing like select * from . $selected .
how can I add the selected value into the query thanks
M
Optimizing where clauses [dev.mysql.com] for more info.
Out of the box you are going to get more mileage from this system than trying to write your own.
Lucene gives you the ability to do more complex searches such as mutli column only searches to:
keyword: "flight:191 destination:new york"
or regular searches..
keyword: "191 new york"
<?php
if (count($_POST) > 0) {
$search = trim(strtoupper($_POST['searchtxt']));
mysql_select_db ("microsearch")
or die ("Cannot connect to the database");
//run query on database where search value is like table fields
$sql = "SELECT * FROM articles where ( ";
$sql .= " UPPER(title) like '%" . $search . "%' OR ";
$sql .= " UPPER(category) like '%" . $search . "%' OR ";
$sql .= " UPPER(body) like '%" . $search . "%' ";
$sql .= ") order by category";
$q = (mysql_query($sql));
echo $q;
$num_rows = mysql_num_rows($q); ///check no of rows
// while there are rows echo output to produce page of results
if($num_rows>0){
while($d = mysql_fetch_array($q)){
$id = $d['id'];
$title = $d['title'];
$category = $d['category'];
$body = $d['body'];
echo "<div class=\"response\"><p><strong>" . $title . "</strong></p>";
//include("resultsheader.php");
echo $id . ' - ';
echo '<br>';
echo 'Category: ' . $category . '<br>';
echo '<br>';
echo 'Body: ' . $body . '<hr>';
echo "</div>";
}
//end while loop
}else{
echo"<p>Sorry, no search result. Please change keywords and try again.</p>";
}//end if
I need to paginate the results anyone have any sugestions
thanks
M