I am working to build a plugin or an MySQL query to aggregate some blog and user meta into a table created by a plugin. The plugin developer has advised me that the table is a flat table, and I can add data to it.
I am using code I found through web search (Google) and have verified that I am retrieving the data I want to use by echoing it to screen.
I have slightly modified the code that displayed the data in an attempt to insert that data into the plugin table wp_store_locator.
It doesn't work. And as you can understand, because I am posting here, I haven't got the faintest clue on how to make corrections.
Any suggestions?
Thanks,
Kirk
<?php
$bcount = get_blog_count();
global $wpdb;
$blogs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE spam = '0' AND deleted = '0' and archived = '0' and public='1'"));
if(!empty($blogs)){
?><ul class="menu"><?php
foreach($blogs as $blog){
$details = get_blog_details($blog->blog_id);
if($details != false){
$addr = $details->siteurl;
$name = $details->blogname;
$blognum = $details->blog_id;
if(!(($blog->blog_id == 1)&&($show_main != 1))){
?>
<li class="menu-item<?php if($counter == get_current_blog_id()){ echo ' current-menu-item';}?>">
Blog ID = <?php echo $blognum; ?><br />
Blog URL = <?php echo $addr; ?><br />
Blog Name = <?php echo $name;?><br />
<?php
$user_id_from_email = get_user_id_from_string( get_blog_option($blognum, 'admin_email'));
$current_site_admin = get_userdata($user_id_from_email);
$kw_fname = (get_user_meta($current_site_admin, 'first_name', true));
$kw_lname = (get_user_meta($current_site_admin, 'last_name', true));
$kw_admin_email = get_bloginfo ( 'admin_email' );
$kw_practice_name = (get_user_meta($current_site_admin, 'practicename', true));
$kw_office_phone (get_user_meta($current_site_admin, 'officephone', true));
$kw_office_city = (get_user_meta($current_site_admin, 'officecity', true));
$kw_office_street = (get_user_meta($current_site_admin, 'officestreet', true));
$kw_office_state = (get_user_meta($current_site_admin, 'officestateprovince', true));
$kw_office_zip = (get_user_meta($current_site_admin, 'officepostcode', true));
</li>
<?php
}
}
}
?></ul><?php
}
$data = array(
'sl_id' => $blognum,
'sl_store' => $kw_practice_name,
'sl_address' => $kw_office_street,
'sl_city' => $kw_office_city,
'sl_state' => $kw_office_state,
'sl_zip' => $kw_office_zip,
'sl_country' => ,
'sl_url' => $addr,
'sl_image' => ,
'sl_private' => NULL,
'sl_neat_title' => NULL,
'sl_pages_url' => NULL,
'sl_pages_on' => NULL,
'sl_lastupdated' => current_time('mysql', 1),
'sl_option_value => NULL
);
$wpdb->insert(wp_store_locator, $data);
?>