i have a website with over 30 pages and 100 modules and i have maybe around 200 queires all over the place.
I was wondering what is the best way to get them all in one place and organized and also somehow to take care of the variable names that will show up after the quires- for example- if a column is names article_id in MySQL database and then i change the column name i can easily fix all the appropriate spots!
any ideas are appreciated
THANKS ALOT
Does this look Right? My table name is games_mlb..
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.
No comments:
Post a Comment