I know all my database connections are right Ive sent data into other tables. Im just looking for a set of eyes to help look into this mysql_query...
mysql_query("INSERT INTO games_mlb (bet_id- gdate- team_one- team_two- status- clock)
VALUES ( ".$bet1[ bet_id ]." - ".$bet1[ date ]." - ".$bet1[ team1_name ]." - ".$bet1[ team2_name ]- ".$bet1[ status ]." - ".$bet1[ clock ]." )";
This is for a search engine- doesn t seem to work though:
1. html form:
<form method="post" action="search.php">
Search for: <input type="text" name="search">
<input type="submit" name="submit" value="Search">
</form>
2. search.php code:
<?php
if $submit {
echo "Searching for: $search<br />";
mysql_connect("mysql"- "username"- "passwd")
Or die(mysql_error());
echo "<p>Welcome to my database.</p>";
mysql_select_db("Country");
$query = "select * from Articles where Author like %$search% ";
$result = mysql_query($query);
echo "<table width= 600 border= 1 cellpadding= 5 ><tr>";
echo "<th align= left width= 200 >Title</th><th align= left width= 100 >Author</th><th align= left width= 200 >Content</th><th align= left width= 100 >Date</th></tr>";
while($row = mysql_fetch_row($result)) {
echo "<tr><td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td></tr>";
}
echo "</table>";
}
?>
THANKS A BUNCH.
ok should drop echo "<p>Welcome to my database.</p>";
so i have Title- Author- Content- Date as columns in a table called Articles. The database is Country. I wish to execute the select * from Articles where Author like %search% query through the form. I.e. would like a simple search engine.
margus- i have added $submit = $_post[ search ] before if $submit but the result is always a blank page. Colanth yes it turns up a blank page. I m not familiar with baretail let me serach it. thanks people.
WOW! we hit the jackpot:
"In search.php :
$submit should be $_POST[submit] and is better used as :
If ($_POST[submit] =="Search"){ //you need the brackets for if.
The where should reference $_POST[search]
Also use mysql_fetch_array rather than row."
Hi Colinc- we hit the jackpot man- this really works. Awsome.
I couldn t follow the string display though - you see i still have a long way to go:-)
What would be the best way on an online quiz- using a php/mySQL framwork to make a person - once they ve started the quiz have to finish or get zero s? Zend? Ajax? Ruby? Perl? Just sessions / cookies? (something else?)
(I d like it if they close the browser that it would submit a call as well- and I m thinking that might have to be done with JavaScript)
i m trying to adapt this code to create a search engine for my database- but it just is not working. I first tested it by creating the "users" database. The following bit probably needs space after LIKE- i tried that as well:
$data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE %$find% ");
Could someone be kind enough to check it for any errors?. That would be greatly appreciated. Thanks a lot people.
http://php.about.com/od/phpwithmysql/ss/php_search.htm
and yes- i tried both the action $PHP_SELF- putting the html and php codes all in one file as well as separating them by using "action=newFile.php".
"first tested it by creating the "users" database"
ok users table :-) database had another name.
"What is the error messages? Need more information. Your query looks OK."
no error messages. When i press search- it returns nothing. tried jim- pizza et was supposed to find something.
Any step by step procedure to make it work. Also how do i downgrade my Browser to IE 6.Any help
i am creating a table with the following data types:
article_Id---> int
title_of_article--->varchar
URL--> varchar
content_summary-->varchar
Date-->date
is this good selection nof data types or should i have gone with BLOB and Text as well? thanks.
article_Id is also auto_increment and a primary key
mailbox: which is better as a datatype for text- blob or varchar? or text?
for an id = integer
or an article s title: varchar or text?
etc.
ah you are a robot :-) cuz you always ask that question- it seems :-)))
ADD:
Seco- thanks a lot: "for content_summary - set it as text (allows for lots and lots of text)".
great that s what i was wondering about because the content summary can be large and i couldnt figure out a good limit. No im not using Unix- windows based accessing MySQL through PHP. Thanks man.
No comments:
Post a Comment