Jump to content

Simmo

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by Simmo

  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
  15. I found the solution to this problem within this forum http://www.phpfreaks.com/forums/php-coding-help/(solved)-php-running-inside-an-iframe-and-session-data-and-ie/
  16. Hi Could someone point me in the right direction for tracking the progress of a file that is downloaded. I need to know when it has finished so another browser window opens. I would also like to get their ip if sucessful and store that into a database. I have read this isn't possible with php alone and found little to help. Thanks
  17. Hi Something strange is happening and I can't understand it. A user can access an availability page of accommodation and book ita room, this works fine, and goes from availability to the booking form and back quite well, carrying the room id of the accommdation and room/s selected in a session. If they close the browser down and open the availability page again all the rooms are there as before, but when they select a room and go to the booking form the session of the room id and the rooms selected are empty. If I do a session destroy and open the browser up again everything works fine again. I have tried this in Chrome and Firefox and it seems to work fine Any help would be appreciated
  18. Thanks, thats the way I'll go
  19. Hi Yes the page checks for a logged in session and redirects if they haven't got one. But when they view their account details using the id from the url they could alter the number and get someone else's account details. I could get their account id at login and put that into a session account id and search using the session account id, then no one could alter it. Just wondered how others address this
  20. Hi I allow users to log in, they are redirected to a page and in the url their account ID is carried e.g. accountid=2. Obviously they could alter the number and potentially see other members details. What is the best way to hide this information? Thanks
  21. All is good, I closed ie and then opened it to start a new session and everything is working. Thanks for your time
  22. Hi Mmmm. I thought the E_ALL may have suppressed an error.(only guessing though) Anyway. To test it I created a killsession.php : <?php ini_set('session.cookie_domain', '.booking-availability.co.uk'); session_start(); session_destroy(); ?> then ran the same scripts, only this time I did get an error on the sread.php: Notice: Undefined index: test in /hom........ Line 7 : echo $_SESSION['test']; I then opened a different browser (ff) and everything was fine. So I guess It was not working because I was creating sessions to test it in different places. I can't understand why my kill sessions script didn't work though? Thanks
  23. Hi That works!! thank you very much. Can you please tell me what the code does.
  24. Hi I can't understand why its not working. I have two test scripts: swrite and sread swrite is in the main root: <?php ini_set('session.cookie_domain', '.maindomain.co.uk'); session_start(); $_SESSION['test'] = "Write text"; ?> and sread is in the subdomain folder: <?php ini_set('session.cookie_domain', '.maindomain.co.uk'); session_start(); echo $_SESSION['test']; ?> I have also tried removing the period before the main domain Any advice would be appreciated 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.