Hi, i'm trying to get some data stored in mysql into a php file without luck.
I created some fields in another php file and they work perfectly, now I just need to call the data from the database to appear in another php file. Could someone please explain why it does'nt seem to want to work ?
Or if simpler, what's the simplest code to get a varchar entry just to appear as text within a php page ?
example: Ive got data stored in customer_rsphere in the Database how would i get that data to appear on the page ?
Yours hopefully,
J#xx
(Scott Perry)
My Sql data into PHP ?
Moderator: General Moderators
Re: My Sql data into PHP ?
I'm assuming that you have connection to your MySQL database, for example:
Once connected create a select statement and retrieve the data from MySQL to your PHP code:
There a ton of ways to handle the data once retrieved from the base. I found that documentation at the PHP website is pretty darn good.
Code: Select all
<?php #mysql_connect.php
// This file contains the database access information.
// This file also establishes a connection to MySQL and selects the database.
// Set the database access information as constants.
DEFINE ('DB_USER', 'username');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'db_name');
// Make the connection
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)
OR die ('Could not connect to MySQL: ' . mysql_error());
// Select the database
@mysql_select_db(DB_NAME)
OR die ('Could not select the database: ' . mysql_error());
?>
Code: Select all
$query = "SELECT column1, column2 FROM table_1;
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$value1_from_table = $row['column1'];
$vallue2_from_table = $row['column2'];
Re: My Sql data into PHP ?
Hi, thanks for the reply, I've posted a link to the forum of Zencart regarding this that explains in more detail including the original code.. My fields i'm trying to get to work are rsphere, lsphere, rcyl, lcyl, raxis, laxis, rnearadd, lnearadd, pupdis, optician.
http://www.zen-cart.com/forum/showthread.php?t=120516
If you could take a look because when I applied your suggested changes it all dissapeared.
Appreciate any assistance !
Cheers
J#xx
(Scott Perry)
http://www.zen-cart.com/forum/showthread.php?t=120516
If you could take a look because when I applied your suggested changes it all dissapeared.
Appreciate any assistance !
Cheers
J#xx
(Scott Perry)