Jump to content

webent

Members
  • Posts

    255
  • Joined

  • Last visited

    Never

Everything posted by webent

  1. Hi, I have an image path field in a csv file which includes both the image path and the image name... what I need to do is separate the two into two different strings to insert into the database... for instance, "http://images.supplier.com/products/474/794043110894.jpg" The thing is, the path is always going to be different, so I can't say, use "http://images.supplier.com/products/474/" as the path and whatever is behind it, use as the image name... Somehow I have to be able to tell it that everything after the LAST forward slash is the image name and what's left is the image path... Can anyone give me a hand with this?
  2. I'm sorry if there was any confusion as to what I'm trying to do... I have to insert the split strings into the database under, product_line, product_master_category, and product_category fields... Thank you all for your responses
  3. Hi, I was hoping someone might be able to tell me if the best way to split a string into multiple strings is to use split? I have read that using preg_split, str_split, and explode are often considered better... I am importing a csv file and one field in particular uses "|" to separate the categories... I need to be able to take the first section and make it say $var1, the second part, if there is one, and make it $var2, and the third part, if there is one, $var3 and throw away any that may follow... Here is one of the field entries for instance, "consumer electronics|phone and telecom|headsets" So say, $CATEGORIES = "consumer electronics|phone and telecom|headsets"; list($var1, $var2, $var3) = split('[|]', $CATEGORIES);
  4. Thank you very much fenway, it worked perfectly... Here's the final query... SELECT DISTINCT product_line FROM webwired_dropshipdirect.products WHERE product_vendor = 'DropShipDirect' AND product_line IN ( 'Jewelry', 'Automotive' ) ORDER BY FIELD( product_line, 'Jewelry', 'Automotive' )
  5. I'm uncertain as to what you mean by using the FIELD() expression, but I will research it and see what I can find out, I'll let you know...
  6. Thank you also Barand, appreciate the help...
  7. Thank you papaface, that worked nicely, here's the code in case anyone else could use it... <?php $states = array( "AK"=>"Alaska", "AL"=>"Alabama", "AR"=>"Arkansas", "AZ"=>"Arizona", "CA"=>"California", "CO"=>"Colorado", "CT"=>"Connecticut", "DC"=>"Washington D.C.", "DE"=>"Delaware", "FL"=>"Florida", "GA"=>"Georgia", "HI"=>"Hawaii", "IA"=>"Iowa", "ID"=>"Idaho", "IL"=>"Illinois", "IN"=>"Indiana", "KS"=>"Kansas", "KY"=>"Kentucky", "LA"=>"Louisiana", "MA"=>"Massachusetts", "MD"=>"Maryland", "ME"=>"Maine", "MI"=>"Michigan", "MN"=>"Minnesota", "MO"=>"Missouri", "MS"=>"Mississippi", "MT"=>"Montana", "NC"=>"North Carolina", "ND"=>"North Dakota", "NE"=>"Nebraska", "NH"=>"New Hampshire", "NJ"=>"New Jersey", "NM"=>"New Mexico", "NV"=>"Nevada", "NY"=>"New York", "OH"=>"Ohio", "OK"=>"Oklahoma", "OR"=>"Oregon", "PA"=>"Pennsylvania", "PR"=>"Puerto Rico", "RI"=>"Rhode Island", "SC"=>"South Carolina", "SD"=>"South Dakota", "TN"=>"Tennessee", "TX"=>"Texas", "UT"=>"Utah", "VA"=>"Virginia", "VT"=>"Vermont", "WA"=>"Washington", "WI"=>"Wisconsin", "WV"=>"West Virginia", "WY"=>"Wyoming" ); ?> <select id="sstate" name="sstate"> <?php foreach ($states as $k => $v) { ?> <option <?php if($shipping_state == $k){echo'selected="selected" ';} ?> value="<?php echo $k;?>"><?php echo $v;?></option> <?php } ?> </select>
  8. Hi, I was wondering if there is a better way to do this, it just seems so sloppy... especially when it's used on several different pages this way... <select id="sstate" name="sstate"> <option <? if(empty($shipping_state)){echo'selected="selected" ';} ?> value="">Select a State</option> <option <? if($shipping_state == "AK"){echo'selected="selected" ';} ?> value="AK">Alaska</option> <option <? if($shipping_state == "AL"){echo'selected="selected" ';} ?> value="AL">Alabama</option> <option <? if($shipping_state == "AR"){echo'selected="selected" ';} ?> value="AR">Arkansas</option> <option <? if($shipping_state == "AZ"){echo'selected="selected" ';} ?> value="AZ">Arizona</option> <option <? if($shipping_state == "CA"){echo'selected="selected" ';} ?> value="CA">California</option> <option <? if($shipping_state == "CO"){echo'selected="selected" ';} ?> value="CO">Colorado</option> <option <? if($shipping_state == "CT"){echo'selected="selected" ';} ?> value="CT">Connecticut</option> <option <? if($shipping_state == "DC"){echo'selected="selected" ';} ?> value="DC">Washington D.C.</option> <option <? if($shipping_state == "DE"){echo'selected="selected" ';} ?> value="DE">Delaware</option> <option <? if($shipping_state == "FL"){echo'selected="selected" ';} ?> value="FL">Florida</option> <option <? if($shipping_state == "GA"){echo'selected="selected" ';} ?> value="GA">Georgia</option> <option <? if($shipping_state == "HI"){echo'selected="selected" ';} ?> value="HI">Hawaii</option> <option <? if($shipping_state == "IA"){echo'selected="selected" ';} ?> value="IA">Iowa</option> <option <? if($shipping_state == "ID"){echo'selected="selected" ';} ?> value="ID">Idaho</option> <option <? if($shipping_state == "IL"){echo'selected="selected" ';} ?> value="IL">Illinois</option> <option <? if($shipping_state == "IN"){echo'selected="selected" ';} ?> value="IN">Indiana</option> <option <? if($shipping_state == "KS"){echo'selected="selected" ';} ?> value="KS">Kansas</option> <option <? if($shipping_state == "KY"){echo'selected="selected" ';} ?> value="KY">Kentucky</option> <option <? if($shipping_state == "LA"){echo'selected="selected" ';} ?> value="LA">Louisiana</option> <option <? if($shipping_state == "MA"){echo'selected="selected" ';} ?> value="MA">Massachusetts</option> <option <? if($shipping_state == "MD"){echo'selected="selected" ';} ?> value="MD">Maryland</option> <option <? if($shipping_state == "ME"){echo'selected="selected" ';} ?> value="ME">Maine</option> <option <? if($shipping_state == "MI"){echo'selected="selected" ';} ?> value="MI">Michigan</option> <option <? if($shipping_state == "MN"){echo'selected="selected" ';} ?> value="MN">Minnesota</option> <option <? if($shipping_state == "MO"){echo'selected="selected" ';} ?> value="MO">Missouri</option> <option <? if($shipping_state == "MS"){echo'selected="selected" ';} ?> value="MS">Mississippi</option> <option <? if($shipping_state == "MT"){echo'selected="selected" ';} ?> value="MT">Montana</option> <option <? if($shipping_state == "NC"){echo'selected="selected" ';} ?> value="NC">North Carolina</option> <option <? if($shipping_state == "ND"){echo'selected="selected" ';} ?> value="ND">North Dakota</option> <option <? if($shipping_state == "NE"){echo'selected="selected" ';} ?> value="NE">Nebraska</option> <option <? if($shipping_state == "NH"){echo'selected="selected" ';} ?> value="NH">New Hampshire</option> <option <? if($shipping_state == "NJ"){echo'selected="selected" ';} ?> value="NJ">New Jersey</option> <option <? if($shipping_state == "NM"){echo'selected="selected" ';} ?> value="NM">New Mexico</option> <option <? if($shipping_state == "NV"){echo'selected="selected" ';} ?> value="NV">Nevada</option> <option <? if($shipping_state == "NY"){echo'selected="selected" ';} ?> value="NY">New York</option> <option <? if($shipping_state == "OH"){echo'selected="selected" ';} ?> value="OH">Ohio</option> <option <? if($shipping_state == "OK"){echo'selected="selected" ';} ?> value="OK">Oklahoma</option> <option <? if($shipping_state == "OR"){echo'selected="selected" ';} ?> value="OR">Oregon</option> <option <? if($shipping_state == "PA"){echo'selected="selected" ';} ?> value="PA">Pennsylvania</option> <option <? if($shipping_state == "PR"){echo'selected="selected" ';} ?> value="PR">Puerto Rico</option> <option <? if($shipping_state == "RI"){echo'selected="selected" ';} ?> value="RI">Rhode Island</option> <option <? if($shipping_state == "SC"){echo'selected="selected" ';} ?> value="SC">South Carolina</option> <option <? if($shipping_state == "SD"){echo'selected="selected" ';} ?> value="SD">South Dakota</option> <option <? if($shipping_state == "TN"){echo'selected="selected" ';} ?> value="TN">Tennessee</option> <option <? if($shipping_state == "TX"){echo'selected="selected" ';} ?> value="TX">Texas</option> <option <? if($shipping_state == "UT"){echo'selected="selected" ';} ?> value="UT">Utah</option> <option <? if($shipping_state == "VA"){echo'selected="selected" ';} ?> value="VA">Virginia</option> <option <? if($shipping_state == "VT"){echo'selected="selected" ';} ?> value="VT">Vermont</option> <option <? if($shipping_state == "WA"){echo'selected="selected" ';} ?> value="WA">Washington</option> <option <? if($shipping_state == "WI"){echo'selected="selected" ';} ?> value="WI">Wisconsin</option> <option <? if($shipping_state == "WV"){echo'selected="selected" ';} ?> value="WV">West Virginia</option> <option <? if($shipping_state == "WY"){echo'selected="selected" ';} ?> value="WY">Wyoming</option> </select>
  9. Hi, I was hoping someone could help me with this... I want to make it so that when a user checks the "Shipping same as billing info" checkbox, it will populate the "<input>" fields with the already populated billing "<input>" info... edit: nevermind, stupid me, I got it... document.getElementById("saddress").value = document.getElementById("baddress").value; document.getElementById("scity").value = document.getElementById("bcity").value; document.getElementById("sstate").value = document.getElementById("bstate").value; document.getElementById("szip").value = document.getElementById("bzip").value;
  10. Ok, it worked, thanks MasterACE14... $completeFilePath = $preurl . "/includes/header.inc"; $handle = file_get_contents($completeFilePath); $search = array("<img src=\""); $replace = array("<img src=\"" . $otherurl . "/"); $fields = str_replace($search,$replace,$handle); echo $fields;
  11. Yeah, that might work, I'm not sure, I'll try it...
  12. Thank you MasterACE14 for your response... I know how to use str_replace() though, my problem is, parsing the include file before it is output...
  13. Was wondering if anyone could point me in the right direction on how I would go about changing the calling location of images to their secure location after the page in which contains the images is called from a "require"? Here is my require... <? require $url . "/includes/header.inc"; ?> Now is there a way to parse that include file before it is output, to change any "<img src="http://" to "<img src="https://"?
  14. Fenway, the reason there are so many seperate queries is because some of the queries access a centralized database ($a_link) and others access settings on a local database ($b_link) ... The other reason there are so many queries is because the sub-categories get queried only after a parent category is selected... You can see how it works at http://imauser.webzcart.com/ , the categories section on the left... Here is the entire piece of code... <? echo ' <div id="categories"> <div id="categories-header"> Categories </div> <div id="product_lines"> <ul>'; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// unset ($query); $product_line_result = mysql_query ("SELECT product_line FROM $local_database.product_lines ORDER BY sort_order", $b_link); while ($product_line_row = mysql_fetch_assoc($product_line_result)) { $query=$query."'$product_line_row[product_line]', "; } if (!empty($query)) { $query = substr_replace($query," ",-2); $vendor_result = mysql_query ("SELECT vendor_name FROM $local_database.vendor_accts", $b_link); while ($vendor_row = mysql_fetch_assoc($vendor_result)) { $pre_query = "SELECT DISTINCT product_line FROM webwired_dropshipdirect.products WHERE product_vendor = '$vendor_row[vendor_name]' AND product_line IN ( $query )"; $pre_result = mysql_query($pre_query, $a_link); while ($pre_row = mysql_fetch_assoc($pre_result)) { $product_line = urlencode($pre_row['product_line']); echo'<li><a href="index.php?product_line=' . $product_line . '">' . $pre_row['product_line'] . '</a></li>'; if ($categories_liststyle_showsubs == "yes") { if (urldecode($_GET['product_line']) == "$pre_row[product_line]") { echo '<ul class="sub">'; $result = mysql_query("SELECT DISTINCT product_master_category FROM webwired_dropshipdirect.products WHERE product_vendor = '$vendor_row[vendor_name]' AND product_line = '$pre_row[product_line]'", $a_link); while ($row = mysql_fetch_assoc($result)) { if (!empty($row['product_master_category'])) { $product_master_category = urlencode($row['product_master_category']); echo '<li><a href="index.php?product_line=' . $product_line . '&product_master_category=' . $product_master_category . '">' . $row['product_master_category'] . '</a></li>'; } if (urldecode($_GET['product_master_category']) == "$row[product_master_category]") { echo '<ul class="sub_sub">'; $sub_result = mysql_query("SELECT DISTINCT product_category FROM webwired_dropshipdirect.products WHERE product_vendor = '$vendor_row[vendor_name]' AND product_line = '$pre_row[product_line]' AND product_master_category = '$row[product_master_category]'", $a_link); while ($sub_row = mysql_fetch_assoc($sub_result)) { if (!empty($sub_row['product_category'])) { $product_category = urlencode($sub_row['product_category']); echo '<li><a href="index.php?product_line=' . $product_line . '&product_master_category=' . $product_master_category . '&product_category=' . $product_category . '">' . $sub_row['product_category'] . '</a></li>'; } } echo '</ul>'; } } echo '</ul>'; } } } } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo ' </ul> </div> </div> '; ?>
  15. I am running mysql version 4.1.22-standard-log on Cpanel version 11.23.4-RELEASE First let me show you the code, it'll help explain what I'm trying to accomplish... unset ($query); $product_line_result = mysql_query ("SELECT product_line FROM $local_database.product_lines ORDER BY sort_order", $b_link); while ($product_line_row = mysql_fetch_assoc($product_line_result)) { $query=$query."'$product_line_row[product_line]', "; } if (!empty($query)) { $query = substr_replace($query," ",-2); $vendor_result = mysql_query ("SELECT vendor_name FROM $local_database.vendor_accts", $b_link); while ($vendor_row = mysql_fetch_assoc($vendor_result)) { $pre_query = "SELECT DISTINCT product_line FROM webwired_dropshipdirect.products WHERE product_vendor = '$vendor_row[vendor_name]' AND product_line IN ( $query )"; $pre_result = mysql_query($pre_query, $a_link); while ($pre_row = mysql_fetch_assoc($pre_result)) { $product_line = urlencode($pre_row['product_line']); echo'<li><a href="index.php?product_line=' . $product_line . '">' . $pre_row['product_line'] . '</a></li>'; Ok, so basically, on the first part of the code, I'm building a query, using a "sort_order" field to put it in a user defined listing order... So what I'd like to accomplish is that the "pre_query" query, I'd like to make it spit out the results in the same order in which it receives the criteria from the built query... So if the "pre_query" looks something like this,... product_line IN ( Jewelry, Automotive ) It will list the relevant data with Jewelry first and not Automotive ... I hope all of this makes sense, thanks in advance for any help...
  16. It seems that its working alright, it'll take me some calculations on my own to make sure its coming up with the right amounts, here's the code, can you take a look at my next set of embedded foreach loops, the ones that are separating out the product_ids and tell me if I did that correctly? $query = mysql_query("SELECT * FROM $local_database.shopping_cart_contents WHERE shopping_cart_id = '$_SESSION[shopping_cart_id]'", $b_link); while ($row = mysql_fetch_assoc($query)) { $vendors[$row['product_vendor']][] = $row; } foreach ($vendors as $vendor) { foreach ($vendor as $row) { # Determine if it has preset shipping or not if ($row['preset_shipping'] == "yes") { # If it does have preset shipping, determine if it is set or free if ($row['preset_shipping_set_or_free'] == "set") { # If the preset shipping is set, then use the preset shipping fee for the shipping rate * the quantity of that item $shipping_rate = $row['preset_shipping_fee'] * $row['shopping_cart_contents_qty']; } if ($row['preset_shipping_set_or_free'] == "free") { # If the preset shipping is free, then the shipping rate is free $shipping_rate = 0; } } if ($row['preset_shipping'] == "no") { # If it does not have preset shipping, calculate the shipping based on the to and from zipcodes and the total combined weight of how many of that item there are $products[$row['product_id']][] = $row; foreach ($products as $product) { foreach ($product as $row) { $sub_total_weight = $row['product_weight'] * $row['shopping_cart_contents_qty']; } } $total_weight += $sub_total_weight; if (isset($_POST['service'])) {$service = $_POST['service'];}else{$service = '03';} $length = '5'; $width = '5'; $height = '5'; $shipping_rate = ups($row['vendor_zipcode'],$shipping_zipcode,$service,$total_weight,$length,$width,$height); } } }
  17. That seems to work to separate out by vendors nicely DarkWater... thank you, but I can't figure out how to get my other variables... Array ( [TestingVendor] => Array ( [0] => Array ( [shopping_cart_contents_id] => 3 [shopping_cart_id] => 3 [product_id] => 31175 [product_vendor] => TestingVendor [vendor_zipcode] => 90210 [shopping_cart_contents_qty] => 1 [product_name] => GPS, NUVI 350 ASIAN AMERICAS [product_price] => 311.02 [product_weight] => 1.9 [preset_shipping] => no [preset_shipping_set_or_free] => [preset_shipping_fee] => 0.00 ) ) ) I tried, $vendors['preset_shipping'], for example and that didn't do it, so I seen that its actually a layer deeper, so I tried, $vendors[]['preset_shipping'], and that errors out...
  18. I get this error "Fatal error: Cannot use [] for reading" for this... $vendors[$row['product_vendor'][]] = $row; I've never seen code like that, so if its a simple mistake on my part, I apologize.
  19. Sorry if I'm misunderstanding you, but if I move the foreach loop outside the while loop, won't I only get one instance of the variable?
  20. But that wouldn't group all products for each instance of every unique product_vendor, you see what I mean?
  21. Exactly, somehow I have to keep the while loop and use some type of foreach logic but without using the foreach loop..., which is really not leaving me with alot of options...
  22. Yeah, I didn't even think of it that way, its not really an array until its outside the loop that's creating it... hmmm, that really poses a problem with my logic then.
  23. Perhaps try going old school on it and try that, pull out the num_views variable, increment it and then stick it back in... i.e., $num_views = $row['num_views'] + 1; $qry = "UPDATE ads SET num_views = $num_views WHERE id = $row[id]";
  24. I was wondering if someone could help me with my loop logic... php 5.2.5 What I'm trying to do is figure shipping costs for a shopping cart... Here is my code so far... $query = mysql_query("SELECT * FROM $local_database.shopping_cart_contents WHERE shopping_cart_id = '$_SESSION[shopping_cart_id]'", $b_link); while ($row = mysql_fetch_assoc($query)) { foreach ($row['product_vendor'] as $vendor) { # Determine if it has preset shipping or not if ($row['preset_shipping'] == "yes") { # If it does have preset shipping, determine if it is set or free if ($row['preset_shipping_set_or_free'] == "set") { # If the preset shipping is set, then use the preset shipping fee for the shipping rate * the quantity of that item $shipping_rate = $row['preset_shipping_fee'] * $row['shopping_cart_contents_qty']; } if ($row['preset_shipping_set_or_free'] == "free") { # If the preset shipping is free, then the shipping rate is free $shipping_rate = 0; } } if ($row['preset_shipping'] == "no") { # If it does not have preset shipping, calculate the shipping based on the to and from zipcodes and the total combined weight of how many of that item there are foreach ($row['product_id'] as $product) { $sub_total_weight = $row['product_weight'] * $row['shopping_cart_contents_qty']; } $total_weight += $sub_total_weight; if (isset($_POST['service'])) {$service = $_POST['service'];}else{$service = '03';} $length = '5'; $width = '5'; $height = '5'; $shipping_rate = ups($row['vendor_zipcode'],$shipping_zipcode,$service,$total_weight,$length,$width,$height); } } $sub_total_shipping_price += $shipping_rate; } The problem lies in the foreach statements, the first foreach statement is meant to separate each set of products that have the same vendor in the while loop... the second foreach statement, inside the first, is meant to separate out each product's combined weight. I'm getting this error however, "Warning: Invalid argument supplied for foreach()" Which I don't understand, because the first argument is an array, which seems to be the only real stipulation to the foreach loop.
  25. Apache 1.3.41 WHM 11.23.2 cPanel 11.23.4-S26138 Hi, could someone tell me how to go about installing mod_vhost_alias.so on my server? Its source file, whatever that means, is located at "/home/cpeasyapache/src/apache_1.3.41/src/modules/standard/mod_vhost_alias.c" I need mod_vhost_alias.so installed in /usr/local/apache/libexec/ directory.
×
×
  • 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.