Rich
02-07-2006, 07:14 PM
Hello,
I have been racking my brain on this for 3 days now and have tried numerous techniques to get this to work. I AM new to mySQL queries, so I know to you seasoned coders this is going to seem very remedial.
I have a table I created. This is the content and how I installed it:
CREATE TABLE this_data
(
site_name varchar(50),
site_url varchar(50),
admin_email varchar(50),
home_it int
);
I want to make a form in the acp that allows me to enter the values for these columns. If they exist already, they will be dropped and the new value inserted.
The output of these values will not be displayed. Instead, they will be placed in a settings file as variables like this (not sure if this is even correct!):
<?php
$site_name = $DB_site->query("SELECT site_name from this_data");
$site_url = $DB_site->query("SELECT site_url from this_data");
$admin_email = $DB_site->query("SELECT admin_email from aws_data");
$home_it = = $DB_site->query("SELECT home_it from this_data");
?>
I have gone through the adminfunctions.php file and that is just confusing me even more.
I know I want to create something like this:
// ## Add Settings ##
//this would actually be: settings_admin.php?do=add
if ($_REQUEST['do'] == 'add')
{
$vbulletin->input->clean_array_gpc('p', array(
'site_name' => TYPE_STR,
'site_url' => TYPE_STR,
'admin_email' => TYPE_STR,
'home_it' => TYPE_INT
));
if (empty($vbulletin->GPC['site_name']) or empty($vbulletin->GPC['site_url']) or empty($vbulletin->GPC['admin_email']) or empty($vbulletin->GPC['home_it']))
{
print_stop_message('invalid_settings_specified');
}
/*Start Query*/
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "this_data
(site_name, site_url, admin_email, home_it)
VALUES
('" . $db->escape_string($vbulletin->GPC['site_name']) . "', '" . $db->escape_string($vbulletin->GPC['site_url']) . "', '" . $db->escape_string($vbulletin->GPC['admin_email']) . "', '" . $db->escape_string($vbulletin->GPC['home_it']) . "')
");
define('CP_REDIRECT', 'settings_admin.php?do=manage');
print_stop_message('saved_settings_successfully', $vbulletin->GPC['settings']);
}
Now I know I have SOME things correct, or at least I think I do!
I just want to be able to see a form with the fields there to add the values. When "submit" is hit, I want it to save that info in the database. If that info exists, I want the new info to replace it.
I would greatly appreciate some help with this. I am really trying to learn how to do all of this but I don't/can't grasp it and I hope with some guidance I will be better capable.
(Please don't post anything like "check out how other people did it, or read this site, etc.) I have been viewing how others have done it and I have been reading so many tutorials on VB and mySQL in general that my eyeballs want to explode. I am just at a point where i am utterly confused and frustrated.
I have been racking my brain on this for 3 days now and have tried numerous techniques to get this to work. I AM new to mySQL queries, so I know to you seasoned coders this is going to seem very remedial.
I have a table I created. This is the content and how I installed it:
CREATE TABLE this_data
(
site_name varchar(50),
site_url varchar(50),
admin_email varchar(50),
home_it int
);
I want to make a form in the acp that allows me to enter the values for these columns. If they exist already, they will be dropped and the new value inserted.
The output of these values will not be displayed. Instead, they will be placed in a settings file as variables like this (not sure if this is even correct!):
<?php
$site_name = $DB_site->query("SELECT site_name from this_data");
$site_url = $DB_site->query("SELECT site_url from this_data");
$admin_email = $DB_site->query("SELECT admin_email from aws_data");
$home_it = = $DB_site->query("SELECT home_it from this_data");
?>
I have gone through the adminfunctions.php file and that is just confusing me even more.
I know I want to create something like this:
// ## Add Settings ##
//this would actually be: settings_admin.php?do=add
if ($_REQUEST['do'] == 'add')
{
$vbulletin->input->clean_array_gpc('p', array(
'site_name' => TYPE_STR,
'site_url' => TYPE_STR,
'admin_email' => TYPE_STR,
'home_it' => TYPE_INT
));
if (empty($vbulletin->GPC['site_name']) or empty($vbulletin->GPC['site_url']) or empty($vbulletin->GPC['admin_email']) or empty($vbulletin->GPC['home_it']))
{
print_stop_message('invalid_settings_specified');
}
/*Start Query*/
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "this_data
(site_name, site_url, admin_email, home_it)
VALUES
('" . $db->escape_string($vbulletin->GPC['site_name']) . "', '" . $db->escape_string($vbulletin->GPC['site_url']) . "', '" . $db->escape_string($vbulletin->GPC['admin_email']) . "', '" . $db->escape_string($vbulletin->GPC['home_it']) . "')
");
define('CP_REDIRECT', 'settings_admin.php?do=manage');
print_stop_message('saved_settings_successfully', $vbulletin->GPC['settings']);
}
Now I know I have SOME things correct, or at least I think I do!
I just want to be able to see a form with the fields there to add the values. When "submit" is hit, I want it to save that info in the database. If that info exists, I want the new info to replace it.
I would greatly appreciate some help with this. I am really trying to learn how to do all of this but I don't/can't grasp it and I hope with some guidance I will be better capable.
(Please don't post anything like "check out how other people did it, or read this site, etc.) I have been viewing how others have done it and I have been reading so many tutorials on VB and mySQL in general that my eyeballs want to explode. I am just at a point where i am utterly confused and frustrated.