PHP mysql_connect for UPDATE example
mysql_select_db("database", $con);
$result = mysql_query("ALTER TABLE jos_acajoom_subscribers ADD interested_in varchar(200); ");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
mysql_close($con)
Joomla MYSQL loadResult example
global $database;
$sql = 'SELECT title FROM #__categories';
$database->setQuery( $sql );
echo $database->loadResult();
$sql = "SELECT * FROM #__categories WHERE title=$title";
$database->setQuery( $sql );
$category = $database->loadRow();
print_r( $category );
$sql = 'SELECT * FROM #__users';
$database->setQuery( $sql );
$user = NULL;
$database->loadObject( $user );
echo "Name: $user->name\n";
echo "Username: $user->username\n";
$sql = 'SELECT * FROM #__categories';
$database->setQuery( $sql );
$rows = $database->loadObjectList();
foreach ( $rows as $row ) {
echo "$row->title: $row->description\n";
}
PHP mysql_connect for SELECT
<?php
$con = mysql_connect("localhost","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$result = mysql_query("SELECT * FROM jos_menu");
while($row = mysql_fetch_array($result))
{
// echo $row['id'] . " " . $row['menutype']. " " . $row['name'];
// echo "<br />";
print "<pre>";
print_r($row);
print "</pre>";
}
mysql_close($con);
?>
PHP mysql_connect for UPDATE
mysql_select_db("database", $con);
$result = mysql_query("ALTER TABLE jos_acajoom_subscribers ADD interested_in varchar(200); ");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
mysql_close($con)
LINK TO MORE DATABASE FUNCTIONS