Jump to content

zander1983

Members
  • Posts

    43
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zander1983's Achievements

Member

Member (2/5)

0

Reputation

  1. but this will give diffrerent new height for each image. i need it like etsy.com where every image has same width and height...
  2. Hi Im working on a market place style website. the framework im using is called elgg. it uses an algoritm to find the right approximate width and height of an image thats being uploaded. but on my site, all heights and widths must be the same. this is difficult because some pictures have much greater width than height and some have much greater height. so whats the best algoritm to use to make an accurate thumbnail of all images uploaded? Thanks
  3. Hi I have an array which looks like this when i do a print_r(): Array ( [0] => Array ( [path] => 1 [order] => 2 ) [1] => Array ( [path] => 2 [order] => 1 ) [2] => Array ( [path] => 3 [order] => 2 ) ) In this instance, I want to change the values of the order key. So I do something like this so that the last array has a path of 3 and an order of 1, and the others have orders of 2 foreach ($old_images as $old_image){ if($old_image['path']==3){ $old_image['order']="1"; } else{ $old_image['order']="2"; } } When i step through, i see that the order is changed, but when i do a print_r(), i get the same result. So even though im resetting the order value of the inside arrays, the multidimensional array does not change.... any ideas?
  4. got it, i used this: <?php // Sort the multidimensional array usort($results, "custom_sort"); // Define the custom sort function function custom_sort($a,$b) { return $a['some_sub_var']>$b['some_sub_var']; } ?>
  5. I have an array and when i do a print_r(), i get this: Array ( [0] => Array ( [path] => 1 [order] => 2 ) [1] => Array ( [path] => 2 [order] => 2 ) [2] => Array ( [path] => 3 [order] => 1 ) ) I want to sort it so that the array with an order of 1 is at the front, i.e. that last array in this case. I tried asort but that didnt do anything...
  6. Hi I want to allow users to upload multiple pictures and allow the user to rearrange the order before being uploaded. I have some javascript which populates a select tag with the image names after selecting an image to upload, and some other javascript that allows the users to move the options up and down the list. So it ouputs code such as this to user if they have selected 2 image files for uploading: <select size="6" id="file_list" name="file_list"> <option value="file_0">DSCN2794.JPG</option> <option value="file_1">DSCN2787.JPG</option> </select> I dont know if this is the correct way of approaching it because then in the back end, I use $_FILES, which doesn't care what order the options are in the select tag.... Any advice? Thanks!
  7. @neil.johnson Thanks for that, thats a pretty comprehensive answer. You seem to be more pro framework than against it. Are there any you recommend? We have being using Elgg. One problem I've noticed amongst our develoeprs (including myself) is when we have a problem, we investigate whether its been done before (amost always yes), and then adapt that solution to suit our problem. With Elgg (and Im assuming all frameworks), we have to adapt the soltiuon to fit our problem, then adapt this solution to fit into the framework. With Elgg, this can lead to hours fighting with vews and actions and registering actions etc. Is this an issue with other frameworks? I have a website which i coded from scratch. Im considering that we use this code base rather than wrestling with Elgg. Heres the site if you're interested: http://www.cottageireland.ie
  8. Is coding from scratch really better though? We have 3 developers and the boss believes we should use a framework because: 1 nobody codes large online applications from scratch anymore (his words) 2 its more stable 3 it forces the different developers to code within certain parameters thereby having a more uniform code base 4 easier to continually add features to the site because of the framework I have always been a code from scratch person. But the arguments for frameworks are growing, especially regarding stability
  9. Just wondering how many people recommend using a framework, such as cakePhp, or coding from scratch? I always coded from scratch, but tried using a Php framework recently called Elgg. It was an absolute nightmare. so how many code from scratch? and how many people use a framework?
  10. ok thanks, im going to keep reading and try to follow these principles:) thanks for help
  11. Hi mjdamato Thanks for your response and you make some interesting points. What is your view on the MVC model? I've been reading this article http://www.phppatterns.com/docs/design/archive/model_view_controller_pattern I have tended to write more procedural code, but the MVC model talks about layers of seperation within code. I dont even use object oriented programming when writing PHP code (I used to in .NET but have gotten out of the habit). The the MVC model and OOP the way to go when writing modern php code? As I expect this site to go live in a few months and have a fairly heavy traffic load, I want to get the structure and style of the code right... Thanks Mark
  12. Hi I've developed a website myself over the last 6 months. I've gotten some investment to develop it further and will now have 2 develoeprs working with me. Its a market place style website so high hits are expected and speed is a must. I was wondering, is my code up to scratch? what exactly are best practices in php? Here's an example of how i get all products on the index page: $sql = "SELECT si.Name, si.ShopItemID, si.Active, si.InStock, si.DateAdded, si.Price, s.CountyID, si.Url as ItemUrl, s.Url as ShopUrl, si.Approved, ii.Url, ii.Active, ii.Front, ii.Thumb, ii.OrderImage, s.CategoryID, s.ShopID, s.Active "; $sql = $sql."FROM shopitem si "; $sql = $sql."Inner Join shop s On (s.ShopID = si.ShopID) "; $sql = $sql."left Join itemimage ii on (ii.ShopItemID = si.ShopItemID And ii.OrderImage = 1) Where 1=1 and si.Active = 1 and si.InStock > 0 and s.Active = 1 and si.Approved = 1 "; if(!$categoryId==0 and !$categoryId==""){ $sql = $sql."And CategoryID = ".mysql_real_escape_string($categoryId); } $sql .= " Group By si.ShopItemID "; and to display it: while ($row = mysql_fetch_array($result)) { echo "<div class='shopItems'>"; echo "<div id='itemIndex'>".$x.".</div>"; if(!$row['Url']==NULL){ echo "<div id='centered'><a href='".WEBSITE_DOMAIN."shops/".$row['ShopUrl']."/".$row['ItemUrl']."'><img alt='".htmlspecialchars($row['Name'])."' title='".htmlspecialchars($row['Name'])."' height='135' width='170' src='images/".htmlspecialchars($row['Front'])."'/></a></div>"; } else{ echo "<div id='centered'><a href='".WEBSITE_DOMAIN."shops/".$row['ShopUrl']."/".$row['ItemUrl']."'><img alt='".htmlspecialchars($row['Name'])."' title='".htmlspecialchars($row['Name'])."' height='135' width='170' src='images/no-img.jpg'/></a></div>"; } echo "<div id='centered'><a href='".WEBSITE_DOMAIN."shops/".$row['ShopUrl']."/".$row['ItemUrl']."'>".htmlspecialchars($row['Name'])."</a></div>"; echo "<p id='centered'>€".htmlspecialchars($row['Price'])."</p>"; echo "</div>"; If($x%4==0){ echo "<div id='clear'></div>"; echo "<div id='divider'></div>"; } $x++; } Is there anything wrong with this approach? Is it best practice and/or faster to use object oriented programming? So I would have a ShopItems class, with members which reflect the attributes of the ShopItems table, and call a function of it to run the sql and set the vales of the members. Am I going in the right direction, towards better practices? Or is what I have done fine? I have used the top approach throught the website, but worry that its a bit of an old-fashioned approach...any advice? thanks Mark
  13. You should use an array. For example: for($i = 0; $i < 10; $i++){ $arr[$i] = "some text ".$i; } echo $arr[5];
  14. I have a SSL Cert for my site. I've put all the files from the http folder to the https folder. What is normally done to redirect people to the https folder? Do i use a url rewrite rule in the .htaccess folder so everytime someone is looking at a http page, its actually a https page?
×
×
  • 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.