Jump to content

loganbest

Members
  • Posts

    43
  • Joined

  • Last visited

Everything posted by loganbest

  1. I'm looping through a json object that was retrieved via ajax. The problem I'm having is that currletter never equals firstletter yet they are the same value sometimes. I have verified that by dumping those valuse side by side in another div $('#dump').append(i+": "+firstletter + " / " + currletter +'<br>'); What's going on? $.each(response.data, function(i, data) { var restname = data.rest_name; if(i == 0) { var firstletter = restname.charAt(0); } var currletter = (!isNaN(restname.charAt(0))) ? "#" : restname.charAt(0); var title = (data.preferred == "Yes") ? '<a href="http://savannahmenu.com/'+ data.url +'"target="_top">'+ data.rest_name +'</a>' : '<a class="nonvip">'+ data.rest_name +'</a>'; var img = (data.image) ? (data.preferred == "Yes") ? '<a href="../'+ data.url +'"target="_top"><img align="left" style="display:block;float:left;margin-right:5px;" src="'+ data.image +'"></a>' : '<img align="left" style="display:block;float:left;margin-right:5px;" src="'+ data.image +'">' : ''; restcontainer += '<table border="0" cellspacing="0" cellpadding="0" width="915">'; if(currletter == firstletter) { restcontainer += '<tr height="2"><td colspan="2" height="2"><div style="background: #ccc; height:2px; width:100%"></div> </td></tr>'; $('#dump').append(i+": "+firstletter + " / " + currletter +'<br>'); } else { restcontainer += '<tr><td colspan="2" height="6"></td></tr>'; restcontainer += '<tr height="20px">'; restcontainer += '<td bgcolor="#000000" valign="bottom" height="20px" style="padding:4px 0px 0px 0px;margin:0px"><span style="color:white;margin-top:3px;font-weight:bold;"> <a name="'+ currletter +'" style="text-decoration: none; color:#fff;">'+ currletter +'</a> Listings</span></td>'; restcontainer += '<td align="right" bgcolor="#000000" valign="bottom" height="20px" style="padding:4px 0px 0px 0px;margin:0px"><a href="#top" style="text-decoration:none; float:right; display:block;" target="_self"><span style="color:white;margin-top:3px;font-weight:normal;">Top </span></a></td>'; restcontainer += '</tr>'; restcontainer += '<tr><td colspan="2" height="6"></td></tr>'; var firstletter = (!isNaN(restname.charAt(0))) ? "#" : restname.charAt(0); } restcontainer += '<tr height="75">'; restcontainer += '<td width="300" valign="middle" style="padding:10px 0px;">'+ img; restcontainer += '<font face="Arial" size="2"><strong>'+ title +'</strong><br> '+ data.phone +'<br> '+ data.address +'<br> '+ data.city +', '+ data.state +' '+ data.zip +'</font></td><td valign="middle">'; restcontainer += (data.single_special) ? '<div class="special singlevip">'+ data.single_special +'</div>' : ''; restcontainer += (data.couple_special) ? '<div class="special couplesvip">'+ data.couple_special +'</div>' : ''; restcontainer += (data.group_special) ? '<div class="special groupvip">'+ data.group_special +'</div>' : ''; restcontainer += '</td></tr></table>'; });
  2. Hi, I’m fairly new to OOPHP and CI so I had a quick question that could be an easy answer for some people. I have a form right now with about 100 checkboxes all with the same name so they will submit as an array of numbers. I also have a table named tag_restaurant_rel which is a relational table that is setup as InnoDB and both `restaurant_id` and `tag_id` are Foreign Keys relating to the corresponding columns in two other tables. The form will be submitted with 1 restaurant_id and several tag_id’s. In the tag_restaurant_rel table there is a record for each tag_id in the array all with the same restaurant_id from the form. What I need to happen is for the form to be submitted and depending on the array of checkbox values the tag_restaurant_rel table will need to delete the records that are not in the array and create a new record for each tag_id in the array. I’m mostly curious in the most efficient way to do this OOP and CI style.
  3. <?php $dir = "../../forms/pdf/"; foreach(glob($dir.'*.pdf') as $pdf){ $files[] = str_replace($dir, '', $pdf); } $files = natcasesort($files); ?> This does not populate the select box. <?php $dir = "../../forms/pdf/"; foreach(glob($dir.'*.pdf') as $pdf){ $files[] = str_replace($dir, '', $pdf); } $files[] = natcasesort($files[]); ?> This produces this error: Warning: natcasesort() [function.natcasesort]: The argument should be an array in /site_homes/www08/intra/pdf-upload/index2.php on line 6
  4. I've tried using that but I keep getting errors so I guess I'm putting it in the wrong place?
  5. I have a bunch of PDF's, some of them having Uppercase first letters and some having lowercase first letters. Right now my code is alphabetizing all of the Uppercase first letters first then all of the lowercase. I want them to be mixed. $dir = "../../forms/pdf/"; foreach(glob($dir.'*.pdf') as $pdf){ $files[] = str_replace($dir, '', $pdf); } then: <select name="current_pdf" id="current_pdf"> <option value="">Please Select a PDF to replace</option> <?php foreach($files as $file) { echo "<option value=\"$file\">" . $file . "</option>"; } ?> </select>
  6. I have a shopping cart and I'm trying to add Previous and Next Product buttons. The next prod works fine but the previous is not. SELECT p.product_Name, p.product_ID, i.prdctImage_FileName, it.imgType_Folder FROM tbl_products p INNER JOIN tbl_skus S ON p.product_ID = S.SKU_ProductID LEFT JOIN tbl_prdtimages i ON p.product_ID = i.prdctImage_ProductID LEFT JOIN tbl_list_imagetypes it ON i.prdctImage_ImgTypeID = it.imgType_ID WHERE it.imgType_SortOrder = 1 AND i.prdctImage_ImgTypeID = 1 AND p.product_OnWeb = 1 AND S.SKU_Stock > 0 AND p.product_ID < '2326' LIMIT 1 if product_ID > '2326' it will return 2327 which is correct. if product_ID < '2326' it will return 429, which should be 2325.
  7. I have two arrays of keywords that I'm pulling from the database. I'm wanting to compare those two arrays and see if ANY of the contents are the same, if they are push that result into another array for later use. while($row_rsCWGetupsell = $cartweaver->db->db_fetch_assoc($rsCWGetupsell)) { $b = array_unique(array_filter(explode(",", preg_replace( '/\s*/m', '', $row_rsCWGetupsell["product_keywords"])), "strlen")); $a = array_unique(array_filter(explode(",", preg_replace( '/\s*/m', '', $row_rsCWGetProduct["product_keywords"])), "strlen")); if($a IN $b) // <--- this is where the comparison should be! $list[] = $row_rsCWGetupsell; }
  8. Data seek worked perfectly... I had that but I had it after the inner loop which I guess made it defective.
  9. I have a while loop nested inside of another while loop to populate a drop-down select box for each result from the parent while loop. The inner loop only gets run once though... any ideas on how to fix this without it being extremely data heavy?
  10. Did you mean to put this? for ($i=$start; $i < $end; $i++) {
  11. I wrote a pagination script but it displays EVERY page in a block. I'm trying to get it to display only the current page # +/- 5 page numbers. for ($i=0; $i < $this->totalPages; $i++) { $pagesEndCount = $i + 1; if(($i-10) < $this->currentPage || $i >= $this->currentPage) { if($i != $this->currentPage) { printf('<a href="'."%s?$this->pagingURL=%d%s", $this->thisPage, $i, $pagingURL .'">'.$pagesEndCount."</a>"); }else{ echo("$this->beforeCurrentPage$pagesEndCount$this->afterCurrentPage"); } if($i != $this->totalPages-1) echo($this->linkDelimiter); }
  12. I'm wanting to copy a complete directory from one location to another with this script: $DOCUMENT_ROOT=$HTTP_SERVER_VARS['DOCUMENT_ROOT']; $startletter = $username{0}; $oldletter = $oldid{0}; $getroot = "/home/whatego/public_html"; @mkdir("/home/whatego/public_html/user_pics/$startletter"); @mkdir("/home/whatego/public_html/user_pics/$startletter/$newid"); $newfolder = "/home/whatego/public_html/user_pics/$startletter/$newid"; $oldfolder = "/home/whatego/public_html/user_pics/$oldletter/$oldid"; $good = copy($oldfolder,$newfolder); if ($good) {echo'Moving pictures success'; } else { echo'Moving pictures failed!';} I always get this error: Warning: copy(/home/whatego/public_html/user_pics/7/7) [function.copy]: failed to open stream: Is a directory in /home/whatego/public_html/changeuser.php on line 89 Moving pictures failed! the copy() manual on php.net said ti would overwrite everything in that directory, though it's not
  13. so you don't know what the other guy is talking about doing it pixel by pixel?
  14. Is there a way in PHP to take three grayscale images (red channel, green channel, and blue channel) and combine them like photoshop does to create an RGB colour image? I know there has to be a way with GD Library's powerful backend.
  15. I have taken the code from another OSCommerce site that uses approximately the same structure as this one. This is the page I'm coding: http://www.numberfoureleven.com/?cPath=21_28 The problem I'm having is getting the pictures to show up for every product instead of just the picture of the last product on every other product. I'm using the $pimage variable that I made right now. It's located close to the bottom. Here is the code: <?php /* $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ $new_products=array(); $new_p_id=array(); ?> <script language="javascript"><!-- function popupWindow(url) { window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=290,height=290,screenX=290,screenY=290,top=150,left=150'); } //--></script> <? $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id'); if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td> <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td> </tr> </table> <?php } $list_box_contents = array(); for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_text = TABLE_HEADING_MODEL; $lc_align = ''; break; case 'PRODUCT_LIST_NAME': $lc_text = TABLE_HEADING_PRODUCTS; $lc_align = ''; break; case 'PRODUCT_LIST_MANUFACTURER': $lc_text = TABLE_HEADING_MANUFACTURER; $lc_align = ''; break; case 'PRODUCT_LIST_PRICE': $lc_text = TABLE_HEADING_PRICE; $lc_align = 'right'; break; case 'PRODUCT_LIST_QUANTITY': $lc_text = TABLE_HEADING_QUANTITY; $lc_align = 'right'; break; case 'PRODUCT_LIST_WEIGHT': $lc_text = TABLE_HEADING_WEIGHT; $lc_align = 'right'; break; case 'PRODUCT_LIST_IMAGE': $lc_text = TABLE_HEADING_IMAGE; $lc_align = 'center'; break; case 'PRODUCT_LIST_BUY_NOW': $lc_text = TABLE_HEADING_BUY_NOW; $lc_align = 'center'; break; } if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) { $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text); } $list_box_contents[0][] = array('align' => $lc_align, 'params' => 'class="productListing-heading"', 'text' => ' ' . $lc_text . ' '); } if ($listing_split->number_of_rows > 0) { $rows = 0; $listing_query = tep_db_query($listing_split->sql_query); while ($listing = tep_db_fetch_array($listing_query)) { $rows++; if (($rows/2) == floor($rows/2)) { $list_box_contents[] = array('params' => 'class="productListing-even"'); } else { $list_box_contents[] = array('params' => 'class="productListing-odd"'); } $cur_row = sizeof($list_box_contents) - 1; for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { $lc_align = ''; switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_align = ''; $lc_text = ' ' . $listing['products_name'] . ' '; break; case 'PRODUCT_LIST_NAME': $lc_align = ''; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $lc_text = '<a class="ml2" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>'; } else { $lc_text = '<a class="ml2" href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> '; } break; case 'PRODUCT_LIST_MANUFACTURER': $lc_align = ''; $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> '; break; case 'PRODUCT_LIST_PRICE': $lc_align = 'right'; if (tep_not_null($listing['specials_new_products_price'])) { $lc_text = '<span>' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> <del class="tx4">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del>'; } else { $lc_text = '<span>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>'; } break; case 'PRODUCT_LIST_QUANTITY': $lc_align = 'right'; $lc_text = ' ' . $listing['products_quantity'] . ' '; break; case 'PRODUCT_LIST_WEIGHT': $lc_align = 'right'; $lc_text = ' ' . $listing['products_weight'] . ' '; break; case 'PRODUCT_LIST_IMAGE': $lc_align = 'center'; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; } else { $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> '; } break; case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> '; break; } $list_box_contents[$cur_row][] = array('align' => $lc_align,'params' => 'class="productListing-data"','text' => $lc_text); $product_contents[] = $lc_text; } $product_query = tep_db_query("select products_description, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$listing['products_id'] . "' and language_id = '" . (int)$languages_id . "'"); $product = tep_db_fetch_array($product_query); array_push($new_products,$product['products_description']); array_push($new_p_id,$product['products_id']); $pimage = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> '; } if (count($list_box_contents)>1)echo '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">'; $col=0; $row=0; for ($i=1;$i<count($list_box_contents);$i++) { $j=$list_box_contents[$i]; if (($col==0) && ($row!=0)) echo '<tr><td height="1" colspan="8" bgcolor="#B59264"></td></tr>'; if ($col==0) echo '<tr><td width="25%" valign="top">'; ?> <table border="0" cellspacing="0" cellpadding="0" width="100%" align="center"> <tr><td align="center" class="m12"><div style="margin-top:5px;"><?=$j[1][text]?> - <strong>Price: </strong><span class="tx5"><?=$j[2][text]?></span></div></td></tr> <tr><td align="center" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td width="50%"><div style="margin-top:5px;" align="center"><?=$pimage?></div> </td></tr> <tr><td height="29" align="center"><div style="margin-top:5px;"></div></td> </tr> </table></td> </tr> <tr><td align="center"><a href="<?=tep_href_link('product_info.php?products_id='.$new_p_id[$i-1])?>"><?=tep_image_button("button_details.gif");?></a></td></tr> <tr><td height="12"></td></tr> </table> <? if ($col==3) { echo ' </td></tr>'; $col=0; $row++; } else { echo ' </td> <td width="1" bgcolor="#B59264"></td> <td width="25%" valign="top">'; $col++; } } if ($col!=0) echo '</td></tr>'; /* new productListingBox($list_box_contents); */ } else { $list_box_contents = array(); $list_box_contents[0] = array('params' => 'class="productListing-odd"'); $list_box_contents[0][] = array('params' => 'class="productListing-data"'); // new productListingBox($list_box_contents); } if (count($list_box_contents)>1)echo '</table>'; if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) { ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td> <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td> </tr> </table> <?php } ?>
  16. Is it possible to make this work correctly without having the hover image stay activated? <a href="index.php?cPath=22"><img src="../../../images/accessoriesminiicongreen.jpg" width="23" height="32" border="0" id="Image2" onMouseOver="MM_swapImage('Image2','','../../../images/accessoriesminiiconblue.jpg',1); dropdownmenu(this, event, 'accessoriesmenu')" onMouseOut="MM_swapImgRestore()"></a>
  17. it will automatically convert an entire db of about 9500 ip addresses?
  18. How would I go about converting a database column of IP address to latitude and longitude and storing all of those in an xml file or txt file so that I can load it and display all of it on a map? Or if there's another better way of doings things.
  19. that works but I need to make the 'reason2' field change values.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.