Jump to content

Simmo

Members
  • Posts

    34
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Simmo's Achievements

Member

Member (2/5)

0

Reputation

  1. I want to able to allow users to upload pictures. Using the GD library I will create/store three different size images for a gallery and displaying the product. The problem is scaling the dimensions for people who have uploaded different sized images. For example, a 4000 x 3000 image will scale to what I want 240 x 180, however I notice that some users have pictures with different dimensions that will not scale to this, e.g. 3008 x 2000 and 3837 x 2551 which will not scale to 240 x180. Can someone please guide me to the best way to handle these different image dimensions so they can be scaled to a common size.
  2. As long as he uses the tables I gave as an example then they will be normalised. Though, I did forget to say to make sure the categoryID in the Category table is a Primary Key. And to make things easire make sure the Primary Key in both tables have auto increment.
  3. A join is needed because he wants to pull out fields in each table, price, product name, category. You can just use the field name in your $rows[''] and using category ID shouldn't be a problem because its going to be the same value in both tables
  4. Example Table called Product with fields ; productID categoryID, productName, productCost....ect (productID is a Primary Key) Table called Category with fields; categoryID, categoryName $sql = "SELECT * From Product, Category Where Product.categoryID = Category.categoryID AND Category.categoryName = '".$_GET['urlVar']."' "; echo $sql; $sqlresult = mysql_query($sql); while ($row = mysql_fetch_array($sqlresult)){ ///pull out the rows } That shouldn't be too far off
  5. echo the sql to see what it says. $sql= mysql_query("SELECT * FROM products, categories WHERE products.category = '$categoryurl' DESC LIMIT 6"); echo $sql; I can't see where you have joined either, try, SELECT * FROM products, categories WHERE products.categoryID = categories.categoryID And products.category = '$categoryurl' DESC LIMIT 6"); I'm guessing the field names, but you get the idea. This is assuming categories has a PK of categoryID
  6. Thanks for that, it all makes sense. Here is my solution: $month = date("m"); $year = date("Y"); date("Y-m-d", strtotime("+1 Month", strtotime(date("Y-m-d", strtotime($year.$month.'01'.' 00:00:00')))))
  7. Hi, Something strange has happend today. I am from the UK the date is March 31st so I am using timezone: date_default_timezone_set('UTC'); I capture the date: $date = date("Y-m-d"); Add a month to the date: date("Y-m-d", strtotime("+1 Month", strtotime($date))) And its comming out as May. If I capture the date through the URL which I do when navigating back: $date = $_GET['date']; Its works and says April Can anyone please advise me on why this is happening. Thanks
  8. Simmo

    while loop

    Not sure exactly what you mean but I would be doing it like this: assuming you have a field in the table called img <?php recent_req2 = "SELECT * FROM $table_m LIMIT 4 "; $res2 = mysql_query($recent_req2); while($img=mysql_fetch_array($res2)){ ?> <a href="img/<?php echo $link['img']; ?>"><img src="img/<?php echo $link['img']; ?>" alt="" width="180" height="100" /></a> <?php } ?>
  9. Simmo

    some help please

    you are refering to a table rank "AND ranks.userID=userdeatils.ID" but you have not have joined it so off the top of my head: UPDATE userdetails Inner Join rank On rank.userID = userdeatils.ID SET glorypoints = glorypoints+'2' WHERE rank > 11 AND rank < 50 AND ranks.userID=userdeatils.ID
  10. Hi, I have done something similar and this help me from the php.net <?php $data[] = array('volume' => 67, 'edition' => 2); $data[] = array('volume' => 86, 'edition' => 1); $data[] = array('volume' => 85, 'edition' => 6); $data[] = array('volume' => 98, 'edition' => 2); $data[] = array('volume' => 86, 'edition' => 6); $data[] = array('volume' => 67, 'edition' => 7); ?> <?php // Obtain a list of columns foreach ($data as $key => $row) { $volume[$key] = $row['volume']; $edition[$key] = $row['edition']; } // Sort the data with volume descending, edition ascending // Add $data as the last parameter, to sort by the common key array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data); ?> But you must remember that wen you loop through the neww sorted array to use the same format as it is in the foreach loop, using the row names.
  11. Hi, A user selects week and a room to book. I put these into an array so I have now have an array of room numbers and dates. I don't want them to book seperate holidays for one accommodation, I have mangaged to stop them booking a two week stay and they an extra week. But I need a way to stop them booking two or three seperate two week holidays. So basically I need to just give an error if the dates they have selected are not consecutive. I have tried many variations of adding and subtracting 7 days and comparing that in the array using a loop based on the room ids being the same. I know the code below doesn't work but it gives an idea of how I been trying. Also assume that the array has aan accomID and date seperated by a comma. function search_break_in_consec_weeks($accomCountValidCheck, $accomID, $date){ $allConsec = false; foreach ($accomCountValidCheck as $key=>$value){ $varArray = explode(', ', $value); $varDate = $varArray[1]; $varAccomID = $varArray[0]; if($accomID == $varAccomID && date("Y-m-d", strtotime($date)) == date("Y-m-d", strtotime($varDate ."+7 days")) || date("Y-m-d", strtotime($date)) == date("Y-m-d", strtotime($varDate ."-7 days"))){ $allConsec = true; break; }else{ $allConsec = false; } } return $countStray; } foreach($accomCountValidCheck as $accomVal){ $varArray = explode(', ', $accomVal); $varAccomID = $varArray[0]; $varDate= $varArray[1]; $valReturnConsec = search_break_in_consec_weeks($accomCountValidCheck, $varAccomID, $varDate); if($valReturnConsec){echo '<b>'.$varAccomID.'</b>'. ' consec<br />';} if($valReturnConsec == false){echo $varAccomID .'not consec<br />';} }
  12. Thanks for reply, I can get the value from that but I want the button to say "Delete", if I put the value there it would just show the number to be deleted which would look strange. Is that what you meant or have I missunderstood. Thanks
  13. Hi I do something similar when I want just the one record but use this line: return !empty($result_array) ? array_shift($result_array) : false;
  14. Hi I have a script that pulls all records out of the database, each record is within a form with no name which results with a lot of forms with essentially the same name. I have an hidden field with the accID which I use to delete the record. This does what I want it to do but have read that you should avoid having mutliple forms, I guess for validation. I know I could do this with a link and use GET, but would rather not having this action showing the details of the deletion in the URL. Is multiple forms so bad? Thanks
×
×
  • 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.