Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Data base store locater?
Old 06-16-2007, 08:26 AM Data base store locater?
Sydpix's Avatar
Drinker I Smoke

Posts: 424
Name: Denny
Location: In a can...
Trades: 0
**edit**

Ok... without dumping 30 g's on school, what would be the best way to learn database functions in php mysql
__________________
.
Village Idiot


Last edited by Sydpix; 06-16-2007 at 09:43 PM..
Sydpix is offline
Reply With Quote
View Public Profile Visit Sydpix's homepage!
 
 
Register now for full access!
Old 06-17-2007, 06:37 PM Re: Data base store locater?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://uk.php.net/manual/en/ref.mysql.php
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-17-2007, 08:16 PM Re: Data base store locater?
Average Talker

Posts: 27
Name: Mike Robinson
Location: London, England
Trades: 0
If you have a web account then check to see if they don't already offer you MySQL and PHP. If you can manage $30 then I bought a book "Beggining PHP MySQL from Novice to Pro" and it seemed to cover most things.

Mike

http://www.amazon.com/Beginning-PHP-...2121794&sr=8-1
mike_bike_kite is offline
Reply With Quote
View Public Profile Visit mike_bike_kite's homepage!
 
Old 06-17-2007, 10:30 PM Re: Data base store locater?
Sydpix's Avatar
Drinker I Smoke

Posts: 424
Name: Denny
Location: In a can...
Trades: 0
I already use PHP and MySql. I'm familiar with inserting Queries in phpMYAdmin and setting up mySql driven scripts.

I want to learn to write simple web applications to make my sites more dynamic.

Thanks for the pointers!
__________________
.
Village Idiot

Sydpix is offline
Reply With Quote
View Public Profile Visit Sydpix's homepage!
 
Old 06-18-2007, 07:11 AM Re: Data base store locater?
Average Talker

Posts: 27
Name: Mike Robinson
Location: London, England
Trades: 0
Just create a file on your server called my_prog.php

Quote:
<HTML>
<BODY>
My first web program dated
<?
echo date( 'Y-m-d' );
?>
</BODY>
</HTML>
Then access that page via your browser and it should print out todays date. You can then expand the PHP code to your hearts content. You'll then want to look at HTML forms and passing parameters from the form to your PHP program.

Next you'll want to access your database from your PHP program and output the data so put in the following code but changing the user name, password, database and table name for your own.
Quote:

<HTML>
<BODY>
My first web program dated
<?
# connect to mysql server
mysql_pconnect('localhost','db_username','db_pwd') or die("Could not connect to db" );

# connect to database
mysql_select_db("db_name") or die('Could not connect to db' );

# run some sql
$sql = "select field_1, field_2 from MyTable";
$result=mysql_query( $sql ) or die( "Problem with $sql" );

# loop through results
while( list( $field_1, $field_2 ) = mysql_fetch_row($result) ) {
echo "$field_1 - $field_2<br>";
}
?>
</BODY>
</HTML>
Then it's just a question of how much effort you want to put in.

Mike
mike_bike_kite is offline
Reply With Quote
View Public Profile Visit mike_bike_kite's homepage!
 
Old 06-18-2007, 09:31 PM Re: Data base store locater?
Sydpix's Avatar
Drinker I Smoke

Posts: 424
Name: Denny
Location: In a can...
Trades: 0
Ok, I think I have (suxcesfully) connected to my database, I'm trying to perform a simple search of my database. I found a script actually, that was pre-written just to use as a guideline and learning purposes... so...

The script requires a query string obviously to include in the search script. Being the noob that I am could someone help me with this query?

// Build SQL Query
$query = "select * from the_table where 1st_field like \"%$trimmed%\"
order by 1st_field"; // EDIT HERE and specify your table and field names for the SQL query


The Table name is homes.

Here is a screen shot of the fields:

$query = "select * from the_table where 1st_field like \"%$trimmed%\"
order by 1st_field";

Should my query look like this?

$query = "select * from homes where id like \"%$trimmed%\"
order by id";

Thanks
__________________
.
Village Idiot

Sydpix is offline
Reply With Quote
View Public Profile Visit Sydpix's homepage!
 
Old 06-19-2007, 03:48 AM Re: Data base store locater?
Average Talker

Posts: 27
Name: Mike Robinson
Location: London, England
Trades: 0
Quote:
We're all newbies at one point or another. Some of us still are!
with over 200 emails on this database forum perhaps it might now be worth seeing how to write basic select statements. I found 2 reasonable looking links for you which might help you learn how SQL works -Mike
mike_bike_kite is offline
Reply With Quote
View Public Profile Visit mike_bike_kite's homepage!
 
Old 06-19-2007, 09:43 PM Re: Data base store locater?
Sydpix's Avatar
Drinker I Smoke

Posts: 424
Name: Denny
Location: In a can...
Trades: 0
Ok, Thanks to your links I have officially connected to mySQL and executed my first search query.

I obviously have a long way to go but I have a couple simple questions:

This obviously just echo's Results if someone performs a search...

Code:
if ($searching =="yes")
{
echo "<h2>Results</h2><p>";
This displays "You forgot to enter a search term" if nothing is entered..

Code:
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
These are filters to strip SQL for HTML ?

Code:
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
This query give me the same 21 results no matter what I type?

Code:
$data = mysql_query("SELECT * FROM homes WHERE upper($field) LIKE'%$pr%' ");


Any suggestions on a simple work around that may narrow the search results based on zip codes? or numbers? I have 21 fields with different zip codes and addresses.

Should I change upper($field) LIKE'%$pr%' to something more defined?


...
__________________
.
Village Idiot


Last edited by Sydpix; 06-19-2007 at 09:46 PM..
Sydpix is offline
Reply With Quote
View Public Profile Visit Sydpix's homepage!
 
Old 06-20-2007, 04:08 AM Re: Data base store locater?
Average Talker

Posts: 27
Name: Mike Robinson
Location: London, England
Trades: 0
Code:
 
$data = mysql_query("SELECT * FROM homes 
WHERE upper(postal_code) LIKE '%$find%' ");
Assuming $find holds the value you are looking for and you just want to search postal_code - you were matching against some variable called $pr.
Code:
 
 
$data = mysql_query("SELECT * FROM homes WHERE upper($field) LIKE '%$find%' ");
Allows you to pick which field you want to match against. I'm guessing there is a pull down of your field names on screen - your original query would fail if this value wasn't valid.

Code:
 
$data = mysql_query("SELECT * FROM homes 
WHERE upper(postal_code) LIKE '%$find%' 
   or upper(type_e) LIKE '%$find%' 
   or upper(type_f) LIKE '%$find%' 
   or upper(short_description_e) LIKE '%$find%' 
   or upper(short_description_f) LIKE '%$find%' 
   or upper(description_e) LIKE '%$find%' 
   or upper(description_f) LIKE '%$find%' 
   or upper(location_e) LIKE '%$find%' 
   or upper(location_f) LIKE '%$find%' 
   or upper(address_e) LIKE '%$find%' 
   or upper(address_f) LIKE '%$find%' ");
Will hopefully match against any field in your table so you won't need your pull down of field names.

Mike
mike_bike_kite is offline
Reply With Quote
View Public Profile Visit mike_bike_kite's homepage!
 
Reply     « Reply to Data base store locater?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28985 seconds with 12 queries