Personally I've never used a GUI to build the interactions between MYSQL and PHP. I've always done the connections directly.
At its core, the connections are very simple. And getting data is also very easy.
As I said try the basic approach, code the connection by hand so you know what it needs to do, and how it needs to do it. And what each part returns.
As en example, here's a quick code snippet that will connect to a database, and query a table, and display the results from it.
CODE<?php
// Setup the connection Paramters: Host, (either an IP address, or a URL, or even localhost if mysql resides in the same physical server as the PHP processor and webserver.),database, user and password
$host ='localhost';
$database = 'dbname';
$user = 'username';
$pass ='pwasword';
//Initiate the connection, usage of mysql_error in the die statement is suggetsed when in development to catch any potential mysql errors.
$conn = mysql_connect($host,$user,$pass) or die(mysql_error());
// Select the database to be used
$db = mysql_select_db($database) or die(mysql_error());
//Setup the query to be run
$query = 'SELECT * FROM mytable';
// Execute the query
$result = mysql_query($query) or die (mysql_error());
//Display the results. mysql_fetch_array, mysql_fetchAssoc, mysql_fetch_row etc... retrieve one row at a time from the result set returned by mysql_query.
echo "<table border=2>";
while($row = mysql_fetch_array($result))
{
echo "<tr><td>" . $row['idmytable'] . "</td><td>" . $row['myfield1'] . "</td><td>" . $row['myfield2'] . "</td></tr>";
}
echo "</table>";
?>
----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
Web & Tech
|
|