View Single Post
  #1  
Old 11-06-2009, 11:04 PM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default More efficient way to code?

Is there a more efficient way to code this? I'm still learning.

PHP Code:
if ($_POST['do'] == 'edit')
{
$vbulletin->input->clean_array_gpc('p', array(
'image_1' => TYPE_NOHTML,
'url_1' => TYPE_NOHTML,
'subtitle_1' => TYPE_NOHTML,
'title_1' => TYPE_NOHTML,
'id_1' => TYPE_INT,
'image_2' => TYPE_NOHTML,
'url_2' => TYPE_NOHTML,
'subtitle_2' => TYPE_NOHTML,
'title_2' => TYPE_NOHTML,
'id_2' => TYPE_INT,
'image_3' => TYPE_NOHTML,
'url_4' => TYPE_NOHTML,
'subtitle_3' => TYPE_NOHTML,
'title_3' => TYPE_NOHTML,
'id_3' => TYPE_INT,
'image_4' => TYPE_NOHTML,
'url_4' => TYPE_NOHTML,
'subtitle_4' => TYPE_NOHTML,
'title_4' => TYPE_NOHTML,
'id_4' => TYPE_INT,
'image_5' => TYPE_NOHTML,
'url_5' => TYPE_NOHTML,
'subtitle_5' => TYPE_NOHTML,
'title_5' => TYPE_NOHTML,
'id_5' => TYPE_INT
    
));
    
    
$db->query_write("UPDATE featured_band SET title = '".$vbulletin->GPC['title_1']."', subtitle = '".$vbulletin->GPC['subtitle_1']."', url = '".$vbulletin->GPC['url_1']."', image = '".$vbulletin->GPC['image_1']."'    WHERE id =".$vbulletin->GPC['id_1']."");
    
    
$db->query_write("UPDATE featured_band SET title = '".$vbulletin->GPC['title_2']."', subtitle = '".$vbulletin->GPC['subtitle_2']."', url = '".$vbulletin->GPC['url_2']."', image = '".$vbulletin->GPC['image_2']."'    WHERE id =".$vbulletin->GPC['id_2']."");
    
    
$db->query_write("UPDATE featured_band SET title = '".$vbulletin->GPC['title_3']."', subtitle = '".$vbulletin->GPC['subtitle_3']."', url = '".$vbulletin->GPC['url_3']."', image = '".$vbulletin->GPC['image_3']."'    WHERE id =".$vbulletin->GPC['id_3']."");
    
    
$db->query_write("UPDATE featured_band SET title = '".$vbulletin->GPC['title_4']."', subtitle = '".$vbulletin->GPC['subtitle_4']."', url = '".$vbulletin->GPC['url_4']."', image = '".$vbulletin->GPC['image_4']."'    WHERE id =".$vbulletin->GPC['id_4']."");
    
    
$db->query_write("UPDATE featured_band SET title = '".$vbulletin->GPC['title_5']."', subtitle = '".$vbulletin->GPC['subtitle_5']."', url = '".$vbulletin->GPC['url_5']."', image = '".$vbulletin->GPC['image_5']."'    WHERE id =".$vbulletin->GPC['id_5']."");
    
    
$vbulletin->url "/index.php?" $vbulletin->session->vars['sessionurl'];  
    eval(
print_standard_redirect('usercss_saved'));
    exit;

PHP Code:
echo '<form action="fb.php" method="post"><input type="hidden" name="do" value="edit" /><div style="height:350px; overflow:auto; padding:0 8px 0px 0px;"><div class="round alt1 twelve" style="padding:8px;margin-top:4px;border:1px solid #dcdcdc">';

$editfeature $vbulletin->db->query_read("SELECT * FROM featured_band ORDER BY id LIMIT 5");

while (
$entry $vbulletin->db->fetch_array($editfeature))
{

echo 
'<div class="boxhead">Spot '.$entry['id'].'</div>
<div class="menu_nl"><div style="float:left;">Title:</div><div align="right"><input name="title_'
.$entry['id'].'" type="text" class="bginput" size="40" value="'.$entry['title'].'"></div></div>
<div class="menu_nl"><div style="float:left;">Sub-Title:</div><div align="right"><input name="subtitle_'
.$entry['id'].'" type="text" class="bginput" size="40" value="'.$entry['subtitle'].'"></div></div>
<div class="menu_nl"><div style="float:left;">Link:</div><div align="right"><input name="url_'
.$entry['id'].'" type="text" class="bginput" size="40" value="'.$entry['url'].'"></div></div>
<div class="menu_nl"><div style="float:left;">URL to Image:</div><div align="right"><input name="image_'
.$entry['id'].'" type="text" class="bginput" size="40" value="'.$entry['image'].'"></div><br />Note: Must be 414 pixels wide by 173 pixels high.</div><input type="hidden" name="id_'.$entry['id'].'" value="'.$entry['id'].'" />';

}

echo 
'</div></div>';

echo 
'<div align="center" style="padding-top:8px;"><input name="" class="btnb" type="submit" value="Save Changes"></div></form>'
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02814 seconds
  • Memory Usage 1,841KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete