Jump to content

CroNiX

Staff Alumni
  • Posts

    1,469
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by CroNiX

  1. The javascript was just showing how to build the filename from the inputs. You don't need it. You didn't describe what you wanted to do beyond just building a filename from the 2 selects.
  2. in form_action.php, you'd do: //grab start/end times, and force them to integers $start = (int)$_GET['startpoint']; $end = (int)$_GET['endpoint']; //build the filename $filepath = '/path/to/file/'; $filename = $start . $end . '.pdf'; //check to see that it actually exists first if (file_exists($filepath . $filename)) { //send file to browser header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($filepath . $filename)); header('Accept-Ranges: bytes'); readfile($filepath . $filename); }
  3. Wouldn't the easiest thing to do is to assign the values of the dropdowns to be numeric? Then take the combination of them to create the filename?
  4. The manual is your friend $result = $db->query($sql); if ($result->num_rows) //...
  5. So the user can only select 1, or 2, timeslots from the same day? Do they need to be consecutive time slots? One problem in helping with this stuff is only you know the business logic required for this application. So our answers may or may not fit into that since we don't know the requirements. We can answer specific questions posed, but the answers may not fit into how the app is supposed to logically work.
  6. If all of these pdf's are being uploaded into a single directory, you can just use PHP's glob() function to retrieve all filenames from that dir. Let's say you had a dir, like /home/user/pdfs And in that dir you had: MyFilename_Jan2015.pdf MyFilename_Feb2015.pdf MyFilename_Mar2015.pdf And you wanted to list them all as links: foreach(glob('/home/user/pdfs/*.pdf') as $filename)) //grab all ".pdf" filenames from this dir { echo '<a href="/path/to/pdf/' . $filename . '">$filename</a><br>'; }
  7. Are you talking about when the files are uploaded to the server you want to name them with those date values? $date = date('MY'); //outputs 3 letter abbreviation followed by a 4 digit year, for the CURRENT MONTH/YEAR. $filename = 'MyFilename_' . $date . '.pdf'; //$filename is now "MyFilename_Jan2015.pdf"
  8. One question I have is, assuming you only want to allow a user to be able to book a single timeslot, why you are using checkboxes and allowing them to select multiple timeslots? What happens if I select them all? It might be better to use links instead, along with a querystring which would be comprised of the date, start time and end time. <a href="/book.php?date=2015-1-22&start=0800&end=0830">8:00am - 8:30am</a> and then in book.php, grab the date, start and end times $date = $_GET['date']; $start = $_GET['start']; $end = $_GET['end']; Then check the database to see if that timeslot is indeed free based on the date, start and end times If it is free, book the timeslot If not, show error message with a link back to the calendar page.
  9. Yes, but the original mysql extension is being removed from php, so all the code you are writing today using the older mysql functions won't work with an upcoming new version of PHP. So it's really best to not use that extension on a new project and to use PDO or mysqli (like Barand showed) unless you want to rewrite all of this stuff when a newer version of PHP comes out and you upgrade to it (or your host does).
  10. Yes, that's HIS db object. You need to adapt the code to however YOU are connecting to and querying the database.
  11. Not going to pretend to be an expert with glob(), but it wouldn't be easy and maybe not possible due to the way your filenames are, and glob's regex is inclusive (can't exclude results). So, I'd either rename your regular non-thumbnail files to something like: q123456-1_full.jpg, q123456-1_tn.jpg and then you can use: foreach (glob('/path/to/images/' . $ID . '-*_full.jpg') as $filename) { or just test each filename when outputting to see if it contains "_tn.jpg" before outputting $ID = 'q123456'; foreach (glob('/path/to/images/' . $ID . '-*') as $filename) { //make sure it's not a thumbnail if (stripos($filename, '_tn.jpg') === FALSE) { echo "$filename</br>"; } } Another option is to put your "full" files in a separate dir from the thumbnails. Then grab all of the full files, and when you need to output the thumbnails you can add the "_tn" to the filename and just change the path.
  12. Yes, but so do ternary operators and most other PHP commands. Just because they are used within a class (which is OOP) doens't make them "oop". Echo works in a class too, but doesn't mean it's "oop". Creating and using classes is OOP. The class itself.
  13. No that has nothing to do with OOP. Your first example is using the ternary comparison operator, which is just a short way if writing if/else statements (javascript has that as well). Your 2nd code block is called an anonymous function.
  14. No. Again having a table per company would be the same as having a table per user. I'm assuming that you will have/require the same info for each company and it wouldn't change from company/company. That's not what a relational database is supposed to do. Please research "relational database" and I think you'll get a better understanding. You'd have a companies table with the fields for the company information. Each company will have a unique ID. Something like: Companies -id (unique company ID) -name -address -website Then users, and the user references the company they work for Users -id (unique user id) -company_id (references companies.id) -first_name -last_name -email So this allows multiple companies, and multiple users per company. Same idea as with the invoices. If a user with an ID of 4 logs in, you look up what company they belong to in the companies table by getting "WHERE companies.id = users.company_id" and load the company data.
  15. I'm sorry, I don't know anything about that graphing class you're using.
  16. Only form fields get transmitted in forms, not stuff from other html. There are no form fields with the name of start or end. Try this: Set the VALUE of the checkbox (the value is what gets transmitted along with the NAME) <input class='fields' type='checkbox' name="booked[]" value="08:00 - 08:15"/> Since you are naming those checkboxes 'booked[]', and allow multiple checkboxes to be submitted, you will need to loop over the array in php. //grab all transmitted "booked" entries from the $_POST array $timeslots = $_POST['booked']; //iterate over the array foreach($timeslots as $timeslot) { //remove spaces from the timeslot as it's in the format of "xx:xx - yy:yy" $timeslot = str_replace(' ', '', $timeslot); //Now looks like "xx:xx-yy:yy" //get the "start" and "end" times, by splitting the string on the dash list($start, $end) = explode('-', $timeslot); //$start now = xx:xx, $end now = yy:yy //just echo out each start/end time to see that it's working echo "Start: $start, End: $end<br>"; }
  17. And where is 'start' and 'end' coming from? Show the HTML as well. You're familiar with your code. We only see what you post and you aren't posting enough info for us to be helpful.
  18. That's because you're printing the whole array using print_r, which stands for "print array". If you want just the file, then do: if ($_POST) { echo $_POST['file']; //only echos the 'file' index from the $_POST array }
  19. Can probably easily do that with glob() $ID = 'q123456'; foreach (glob('/path/to/images/' . $ID . '-*') as $filename) { echo "$filename size " . filesize($filename) . "\n"; }
  20. $booked = mysql_real_escape_string($_POST['booked']); You don't set any values for your checkbox inputs, so $_POST['booked'] isn't transmitting anything.
  21. So it's showing up after you submit the form? Not sure if it's the forum doing it or your code converting the > to &gt, but try: if ($_POST) { echo '<pre>'; print_r($_POST); echo '</pre>'; }
  22. Well, you'd have a registration system. Once their data is saved in the db, they now have a unique ID (auto-incrementing ID column). You wouldn't have a different database for each user. Just one for all. You'd use their ID in all of the other tables. Like in the invoices table, you'd have a user_id column in addition to your other regular fields. Then when querying the database, you just grab everything for that user_id, or store it using their user_id, or whatever. That's the purpose of a relational database.
  23. Sorry, that's still pretty vague since you used "select *" instead of listing the actual column names. What does $row look like after you perform the query? Do you have a separate table to store the image names? If you did then you could just use a JOIN and not store 'PIX' at all in the listings table. That's the purpose of a relational database. listings: -id listing_images: -ID -listing_id (references listings.id) -image_name
×
×
  • 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.