We help IT Professionals succeed at work.

How do I use PHP to contain logic and database operations?

curiouswebster
curiouswebster used Ask the Experts™
on
I am new to PHP and expect to use DreamWeaver to write an iPhone app. But when I look at PHP I see marked up HTML and do not yet have a feeling for the server side computations.

Please send me sample links that can show me code which executes on the server to set field values, for example, from a database.

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jason C. LevineDon't talk to me.
Commented:
Something like this?

Source: http://www.w3schools.com/php/php_mysql_update.asp

<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

mysql_query("UPDATE Persons SET Age=36
WHERE FirstName='Peter' AND LastName='Griffin'");

mysql_close($con);
?> 

Open in new window

curiouswebsterSoftware Engineer

Author

Commented:
If my target platforms are iPhone and Android, I presume I would use SQLLite. And I suppose I have no worries of a SQL injection attack.

Regarding your post, I still do not see code logic which I would need in order to manipulate the data. So I guess the answer is Javascript, right?
Don't talk to me.
Commented:
JQuery mobile or straight HTML5, yes.
curiouswebsterSoftware Engineer

Author

Commented:
But I did see in your last posted link that I can get some amount of logic into a PHP function. I guess PHP's more powerful that I had thought it was.

Thanks!
Jason C. LevineDon't talk to me.

Commented:
It's a full programming language.  Not sure what led you to think otherwise.