Jump to content

loganbest

Members
  • Posts

    43
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

loganbest's Achievements

Member

Member (2/5)

0

Reputation

  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); }
×
×
  • 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.