MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old May 22nd, 2004, 07:20 AM
glen279 glen279 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 glen279 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Really Basic PHP / MySQL Help

Hello People.
I am really hoping you can help me, I'm 15 and just starting to learn php. I know how to set up a MySQL database and I know some basic PHP. I was wondering if anybody could tell me how to query a database? What I really want to do is a New and Updates thing for my personal site. I want two things, a date, and the new for that date. I have the basic idea how it works I just need a little help.

Thanks.
Glen

Reply With Quote
  #2  
Old May 22nd, 2004, 09:52 AM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
hmmm.... you should look at php.net. They have a great section that will explain all the different codes fore you, and then mysql.com. They will tell you how to query the db.

BUT. Here is the genneral idear:

PHP Code:
 $SQL mysql_query(select from db where '-=what ever the limits of the search might be=-'); 
this querys the db according to the where claus. instead of the "select" you can use the update or delete. these does not need the " * ".

PHP Code:
 $sql mysql_fetch_array(init result of query); 
this putes all the results from teh query into an array. This can be fetched like this:
PHP Code:
 $sql['field name'


- Pheifel

Reply With Quote
  #3  
Old May 22nd, 2004, 10:47 PM
gallifray gallifray is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Pennsylvania
Posts: 16 gallifray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 3 sec
Reputation Power: 0
if you want a really great book ( at least in my opinion ) on learning php, get PHP Fast and Easy Web Development by Julie C. Meloni. I got it and it helped me out a great deal and I still use it for reference though it is mainly good for learning the basics. After you learn the basics, all you need is the PHP and MySQL online documentation.

Reply With Quote
  #4  
Old May 23rd, 2004, 10:10 AM
q3utom q3utom is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 16 q3utom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hey I started learning php when I was 16 and been doing it for a year. What helped me was looking at hotscripts.com and the example scripts there for updates and inserts then learning that way.

PHP and MySql for dummies helped me a lot. php.net is also very useful.

Reply With Quote
  #5  
Old May 25th, 2004, 01:52 PM
ClearWater ClearWater is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 ClearWater User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Glen,

One way to establish a connection with a mySQL server is with the following function:

PHP Code:
function ConnectToDB()
{
    if (
$objDBConn mysql_connect ("myServerName""myUserName""myPassword"))
    {
        
mysql_select_db ("myDBName"$objDBConn);
        return 
true;
    }
    else
    {
        return 
false;
    }



This function will return a true if the connection was successfully made, and a false if the connection was not made. After the ConnectToDB function has been called by your script, you can do something as follows:

PHP Code:
 $objRecordSet mysql_query ("SELECT * FROM tbMyTable"); // create a recordset from the data retrieved by the SQL statement in mysql_query function
 
 
for ($iCounter 0$iCounter mysql_num_rows ($objRecordSet); $iCounter ++)
 {
    
$objCurrentRow mysql_fetch_array ($objRecordSet); // go through the recordset, 1 row at a time and store the row data in $objCurrentRow
    
print ($objCurrentRow["myRowName1"] . " " $objCurrentRow["myRowName2"]);
 } 


Additionally, http://us3.php.net/manual/en/ref.mysql.php has a list of available PHP functions that you can use with mySQL. Hope that helps.

Thanks, ClearWater

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Really Basic PHP / MySQL Help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway