Jump to content

PHP Learner

Members
  • Posts

    37
  • Joined

  • Last visited

Everything posted by PHP Learner

  1. Yep it's flawed isn't. Ok back to the drawing board, so I know how to grab the date BETWEEN start and finsh dates in a mysql query, but how do you grab all dates from all the rows in one query and crank them out into an array which can be used to find the row it came from to gather the rest of the data?
  2. Yep your absolutely right Psycho. The numbers are actually dates (month and day) which I need for something. They exist in a row which has a start date and a finish date column (amongst others) and I have had to fill in the dates in between. I'm gonna post the code here, it's probably a bit shite but anyway. What I need to do is compare an inputted date with a value in the array and find the key which reffers to the row (rowNo) it came from. Not sure if that makes much sense to you or not, anywayz tha code. rowNo | startDate | finishDate | other columns 1 | 0301 | 0304 | stuff while($row = mysql_fetch_array($grabDates)) { $startDate = $row['startDate']; $finishDate = $row['finishDate']; $rowNo = $row['rowNo']; $arrayDate = $startDate; $break = ''; while($break !== 'something') { if ($break == 'break') {$arrayEntry .= $arrayDate;} else {$arrayEntry .= $arrayDate . ', ';} if ($break == 'break') {$break = ''; $arrayDate = ''; break;} if ($arrayDate == '1231') {$arrayDate = '0101';} else {$arrayDate++;} $countDateString = strlen($arrayDate); if ($countDateString == '3') {$arrayDate = '0' . $arrayDate;} if ($arrayDate == $finishDate) {$break = 'break';} } $numbers[] = array($arrayEntry); $arrayEntry = ''; } // End - while($row = mysql_fetch_array($grabDates)) { So I'm trying to build the array with key value pairs with a string seperated by commas in each key. Roughly something like this... Array [0] => (1234, 5678, 9012, 3456) [1] => (3456, 9012, 5678, 1234) [2] => (1234, 5678, 9012, 3456) etc...
  3. Hi all, This seems like it should be really simple but to me it's not. I have an array in a variable called $numbers. When I run print_r ($numbers) I get the following... $earchForNumber = '0304'; // Array called $numbers Array ( [0] => Array ( [0] => 0219, 0220, 0221, 0222, 0223 ) [1] => Array ( [0] => 0301, 0302, 0303, 0304 ) [2] => Array ( [0] => 1230, 1231, 0101, 0102 ) ) if (in_array($earchForNumber, $numbers)) {echo 'The key is' . $key;} What I need to do is search for a number within all of the sub arrays and find the key which it belongs to. So if I wanted to find the key for the value of $earchForNumber (0304) it would return a key of 1. There are tons of posts on stack overflow about this sort of thing but I can't find any that perform this task. I played around with inarray() but couldn't get any joy. Any ideas?
  4. I wrote the following code to create a set of 12 php calendars to display specific entries from a database. I have found many posts about converting a date into an integer but can find nothing to convert an integer into a date or more specifically in this case a month. The interesting thing about all of this is that it accepts and integer as a string in a concatinated set of values initially but won't accept the $month after the change at the end of the code when it returns to continue the loop. Can anyone tell me where I'm going wrong here? <?php $month = date("m"); // Initate $month to current month $twelveCount = '1'; // Set count to 1 for loop while($twelveCount != '13') { // Create loop condition to break at 13 producing 12 calendars $monthName = date("F", strtotime($month)); // Grab name of month from $month variable $year = date("Y"); // Initiate $year from current year $firstDate = $month . '/01/' . $year; // Calculate first day of the month, NOTE: It accepts the string integer here; $firstDay = date("D", strtotime($firstDate)); // Grab day of the first date $firstDay = strtoupper($firstDay); // Capitalise first day string $lastDay = cal_days_in_month(CAL_GREGORIAN, $month, $year); // Grab last day of the month $i = '1'; // Set integer to 1 for begining of auto incremental date display $lastDayPlusOne = $lastDay + 1; // Set limit for loop break when days are complete if ($firstDay == 'SUN') {$skipDays = '0';} // Skip spaces on calendar to equal actual first day if ($firstDay == 'MON') {$skipDays = '1';} if ($firstDay == 'TUE') {$skipDays = '2';} if ($firstDay == 'WED') {$skipDays = '3';} if ($firstDay == 'THU') {$skipDays = '4';} if ($firstDay == 'FRI') {$skipDays = '5';} if ($firstDay == 'SAT') {$skipDays = '6';} $count = '0'; // Iniate $count for loop break when first day is in the correct position $calendarDisplay .= '<div style="float:left; width:182px; margin:0px 0px 7px 7px;"> <div style="float:left; width:161px; text-align:left; margin-bottom:5px;">' . $monthName . ' ' . $year . '</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">SUN</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">MON</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">TUE</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">WED</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">THU</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">FRI</div> <div style="float:left; width:23px; margin:0px 3px 3px 0px; background-color:#CCC; font-size:10px; text-align:center;">SAT</div> <div style="float:left; width:182px;">'; // Create day names for header while($count != $skipDays) { // Output spaces to match day of the week before dates begin $calendarDisplay .= '<div style="float:left; width:23px; padding:4px 0; margin:0px 3px 3px 0px;"></div>'; $count++; } while($i != $lastDayPlusOne) { // Output dates inline with days in header $calendarDisplay .= '<div style="float:left; padding:4px 0; width:23px; margin:0px 3px 3px 0px; background-color:#0C0; font-size:10px; text-align:center;">' . $i . '</div>'; $i++; } $calendarDisplay .= '</div></div>'; // End calendar display // This is where it all goes wrong... if ($month == date("m", strtotime("1/10/10"))) {$month = date("m", strtotime("2/10/10")); echo $month;} if ($month == '02') {$month = date("m", strtotime("3/10/10")); echo $month;} if ($month == '03') {$month = '04'; echo $month;} /* if ($month == '04') {$month = date("m", strtotime("5/10/10")); echo $month;} if ($month == '05') {$month = date("m", strtotime("6/10/10")); echo $month;} if ($month == '06') {$month = date("m", strtotime("7/10/10")); echo $month;} if ($month == '07') {$month = date("m", strtotime("8/10/10")); echo $month;} if ($month == '08') {$month = date("m", strtotime("9/10/10")); echo $month;} if ($month == '09') {$month = date("m", strtotime("10/10/10")); echo $month;} if ($month == '10') {$month = date("m", strtotime("11/10/10")); echo $month;} if ($month == '11') {$month = date("m", strtotime("12/10/10")); echo $month;} if ($month == '12') {$month = date("m", strtotime("01/10/10")); echo $month;} */ $twelveCount++; // Increment $twelveCount by 1 } // End while($twelveCount != '13') { echo $calendarDisplay; // Echo result out to page ?>
  5. I want to thank you very much for your patients Barand, Im sorry if this is difficult to understand but the fact of the matter is that the description of the rooms will not need a table because it will be hard coded if you like into its own page. There simply is no need for a rooms table because these details are not the kind that change very often unless they are altering the premises in some way and if or when that is so, I'll cross that bridge. So it's just the room name/number we need which we will add to the table like so. ALTER TABLE `bookingscalendar` ADD `roomId` VARCHAR( 30 ) NOT NULL ; That said, the main focus is the search function for the bookingscalendar which after optimising the original table (with much gratitude!) is where we began. Cheers mate, php LEARNER
  6. Oh sorry, It's this code here isn't it? $db = new mysqli(HOST, USERNAME, PASSWORD, 'test'); $prefDate = '2013-06-24'; // preferred date $reqDays = 3; // days required $sql = "SELECT bookingdate FROM bookingscalendar WHERE status = 'available' AND bookingdate >= CURDATE() ORDER BY bookingdate"; $res = $db->query($sql); $dates = $earlier = $later = array(); $count = 0; $preferred = new DateTime($prefDate); $prevDay = new DateTime(); $prevDay->modify('-1 days'); /******************************** * search for N cosecutive dates *********************************/ while (list($bd) = $res->fetch_row()) { $dt = new DateTime($bd); if ($dt->diff($prevDay)->days==1 ) { $dates[] = $dt->format('Y-m-d'); } else { $dates = array($dt->format('Y-m-d')); } if (count($dates)>=$reqDays) { if ($dt->diff($preferred,0)->format('%R%a') > 1-$reqDays) { $earlier = array_slice($dates, -$reqDays); // last available N days prior } else { $later = array_slice($dates, -$reqDays); // next available N days break; } } $prevDay = clone $dt; } // output search results if ($later[0] != $prefDate) { echo "Prior dates: " . join(' | ', $earlier) . '<br>'; echo "Later dates: " . join(' | ', $later); } else { echo join(' | ', $later) . " is available"; }
  7. Hello mate, I think the room table isn't necessary at this stage, all the information for the types of rooms and facilities will be in each page. A prices table is a good suggestion I will be making the client a small CMS to change their requirements depending on fluctuations in their tariffs etc as you outlined above so thanks for that. The brass tacks of it all now really is the way we work with the bookingsCalendar table you tweaked this morning, care to print some logic Barand?
  8. Nice! That's got to be the most efficient calendar table there is. Well the invoice table is probably something I'll come back to refine a bit later on, for now if I'm right here it will serve it's purpose. It will be necessary to have the ability to check for a number of rooms at a time, I was going to use a different table for each room to achieve that. Now that you mention it tho, do you reckon we should add a room number/name column after autoInc or something? I'm really quite out of my depth as far as processing will go here, what would you suggest?
  9. Sorry screwed that up. Ok so above, I grab the dates from the sessions created when a calendar is used (date and nights submitted) and posted back to the bookings page for processing. So this is pretty much where my expertise runs dry lol. Question! 1) How do you tell mysql to search for dates that don't already exist? So you want to tell it to... SELECT * FROM bookingsCalendar WHERE bookingDate='$QueryDate' But how do you say and include the next 7 days in mySQL talk? Question! Next step I suppose if we assume that the dates have been booked on say 01/06/2013 for 7 days, 2) How do we search for the next available block of 7 days despite the possibility of other blocks of dates existing in the table. The search has to find previous dates as well as future dates on the table. Really its a bid to aid the customer from loosing the will to live lol, but in all seriousness is highly practical and could make the difference between a conversion and nothing at all. What do you think B?
  10. <?php session_start(); if (!isset($_SESSION['CalendarDate'])) {$_SESSION['CalendarDate'] = date("d/m/Y");} $NumberOfNights = $_SESSION['NumberOfNights']; if ($NumberOfNights == '7 Nights') {$Selected_1 = 'selected="selected"';} if ($NumberOfNights == '8 Nights') {$Selected_2 = 'selected="selected"';} if ($NumberOfNights == '9 Nights') {$Selected_3 = 'selected="selected"';} if ($NumberOfNights == '10 Nights') {$Selected_4 = 'selected="selected"';} if ($NumberOfNights == '11 Nights') {$Selected_5 = 'selected="selected"';} if ($NumberOfNights == '12 Nights') {$Selected_6 = 'selected="selected"';} if ($NumberOfNights == '13 Nights') {$Selected_7 = 'selected="selected"';} if ($NumberOfNights == '14 Nights') {$Selected_8 = 'selected="selected"';} if ($NumberOfNights == '15 Nights') {$Selected_9 = 'selected="selected"';} if ($NumberOfNights == '16 Nights') {$Selected_10 = 'selected="selected"';} if ($NumberOfNights == '17 Nights') {$Selected_11 = 'selected="selected"';} if ($NumberOfNights == '18 Nights') {$Selected_12 = 'selected="selected"';} if ($NumberOfNights == '19 Nights') {$Selected_13 = 'selected="selected"';} if ($NumberOfNights == '20 Nights') {$Selected_14 = 'selected="selected"';} if ($NumberOfNights == '21 Nights') {$Selected_15 = 'selected="selected"';} if (isset($_POST['SubmitCalendar'])) { $CalendarDate = $_POST['CalendarField']; $_SESSION['CalendarDate'] = $_POST['CalendarField']; $NumberOfNights = $_POST['NumberOfNights']; $_SESSION['NumberOfNights'] = $NumberOfNights; if ($NumberOfNights == '7 Nights') {$Selected_1 = 'selected="selected"'; $NightsForQuery = 7;} if ($NumberOfNights == '8 Nights') {$Selected_2 = 'selected="selected"'; $NightsForQuery = 8;} if ($NumberOfNights == '9 Nights') {$Selected_3 = 'selected="selected"'; $NightsForQuery = 9;} if ($NumberOfNights == '10 Nights') {$Selected_4 = 'selected="selected"'; $NightsForQuery = 10;} if ($NumberOfNights == '11 Nights') {$Selected_5 = 'selected="selected"'; $NightsForQuery = 11;} if ($NumberOfNights == '12 Nights') {$Selected_6 = 'selected="selected"'; $NightsForQuery = 12;} if ($NumberOfNights == '13 Nights') {$Selected_7 = 'selected="selected"'; $NightsForQuery = 13;} if ($NumberOfNights == '14 Nights') {$Selected_8 = 'selected="selected"'; $NightsForQuery = 14;} if ($NumberOfNights == '15 Nights') {$Selected_9 = 'selected="selected"'; $NightsForQuery = 15;} if ($NumberOfNights == '16 Nights') {$Selected_10 = 'selected="selected"'; $NightsForQuery = 16;} if ($NumberOfNights == '17 Nights') {$Selected_11 = 'selected="selected"'; $NightsForQuery = 17;} if ($NumberOfNights == '18 Nights') {$Selected_12 = 'selected="selected"'; $NightsForQuery = 18;} if ($NumberOfNights == '19 Nights') {$Selected_13 = 'selected="selected"'; $NightsForQuery = 19;} if ($NumberOfNights == '20 Nights') {$Selected_14 = 'selected="selected"'; $NightsForQuery = 20;} if ($NumberOfNights == '21 Nights') {$Selected_15 = 'selected="selected"'; $NightsForQuery = 21;} $CalendarDate = str_replace("/", "-", "$CalendarDate"); $QueryDate = date("Y-m-d", strtotime($CalendarDate)); include_once('../connect/connect.php'); //$bookingsCalendar = mysql_query("INSERT INTO bookingsCalendar (bookingDate, status, invoiceId) VALUES ('now()', 'booked', 'invoiceId')"); } // End - if (isset($_POST['SubmitCalendar'])) {
  11. My word! lol, Guru is certainly apt, many thanks for your efforts Barand. So if a fresh new approach is what the doctor ordered thats what we will do. In this case, by the look of it, I'll make 3 tables to spread out or 'normalize' the data, and your right making entries only when is necessary will save an awful lot of clutter. CREATE TABLE `bookingsCalendar` ( `autoIncId` int(10) NOT NULL AUTO_INCREMENT, `bookingDate` date NOT NULL, `status` enum('available','booked') NOT NULL, `invoiceId` varchar(30) NOT NULL, PRIMARY KEY (`autoIncId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `invoice` ( `invoiceId` varchar(30) NOT NULL, `invoiceRef` varchar(30) NOT NULL, `invoiceDate` date NOT NULL, `custId` varchar(30) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `customer` ( `custId` varchar(30) NOT NULL, `firstName` varchar(20) NOT NULL, `lastName` varchar(20) NOT NULL, `email` varchar(45) NOT NULL, `phoneNo` tinyint(4) NOT NULL, `address` varchar(255) NOT NULL, `county` varchar(50) NOT NULL, `country` varchar(30) NOT NULL, `postcode` varchar(10) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Would you say these values are appropriate? So the next step is to take a date from the calendar widget and amount of nights they want to stay (for testing sake best to keep it to 7 nights I think). I'll have to go away and write some sort of script for this now as best I can and I'll come back to post it in a bit, it will probably be clunky but I am a learner after all.
  12. Hmmm, looks like it might be a server error and not the script.
  13. Alright Barand, I would love to try out your script but I wonder if you can help me with populating the table first? See, the following scripts work with the older versions of phpmyadmin but yesterday I got a newer version and it's stopped working with a very generic error(500). Reckon you could cast your professional eye accross this code quickly and see if it can be made more efficient or see what needs doing to it? CREATE TABLE `table_setup` ( `number` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (`number`) ) COLLATE='utf8_general_ci' ENGINE=MyISAM; INSERT INTO table_setup VALUES(NULL); INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; INSERT INTO table_setup SELECT NULL FROM table_setup; DELETE FROM table_setup WHERE NUMBER > 18264; CREATE TABLE `BookingsCalendar` ( `AutoIncNo` SMALLINT(2) NOT NULL AUTO_INCREMENT, `BookingDate` DATE NOT NULL, `Status` varchar(10) NOT NULL DEFAULT 'available', `InvoiceRefference` varchar(40) NOT NULL, `CustomerName` varchar(40) NOT NULL, `CustomerEmail` varchar(40) NOT NULL, `CustomerPhone` varchar(30) NOT NULL, `Address` varchar(100) NOT NULL, `County` varchar(40) NOT NULL, `Country` varchar(30) NOT NULL, `PostCode` varchar(10) NOT NULL, PRIMARY KEY (`AutoIncNo`) ) COLLATE='utf8_general_ci' ENGINE=MyISAM; INSERT INTO BookingsCalendar (BookingDate) SELECT DATE_ADD('2013-05-05', INTERVAL number-1 DAY) FROM table_setup WHERE NUMBER < 18264; Gotta say, appreciate this very much. L-Plate
  14. Would this work in it's place? $prefDate = $_SESSION['CalendarDate']; // preferred date $reqDays = $NightsForQuery; // days required $res = mysql_query("SELECT BookingDate FROM BookingsCalendar WHERE Status='available' AND BookingDate >= CURDATE() ORDER BY BookingDate"); //$db = new mysqli(ip, usrname, psswrd, 'databasename'); //$res = $db->query($sql);
  15. Well your certainly the person I need to speak to! Thanks for your input, the script returns a parse error on the same line as the connection... $db = new mysqli(HOST, USERNAME, PASSWORD, 'test'); I'm not familiar with the mysqli() command yet, so its quite possible that I've F'd it up... Parse error: syntax error, unexpected T_DNUMBER (on the same line) Oh joy, This is probably very simple, if your not brain fried.
  16. Hello coder buddies, I have made this table with all the dates of the years going upto 2063, to keep it simple, it contains 3 columns which have been pre-popluated, example as follows... Actual table AutoIncNo | BookingDate | Status The calendar is in 2 parts. 1) Calendar to select a date 2) A list menu to select the amount of nights they wish to stay. So I take the original date (the one they select) and rearrange the format to suit the table... PHP Code: $CalendarDate = str_replace("/", "-", "$CalendarDate"); $QueryDate = date("Y-m-d", strtotime($CalendarDate)); Connect to the database... PHP Code: include_once('../connect/connectdatabase.php'); Run the first query to check if the dates they require are available. $QueryDate is the date they select $NightsForQuery is the amount of nights they want to stay PHP Code: $CalendarQuery = mysql_query("SELECT * FROM BookingsCalendar WHERE BookingDate='$QueryDate' LIMIT 1"); while($row = mysql_fetch_array($CalendarQuery)) {$AutoInc = $row["AutoIncNo"];} $AutoInc2 = $AutoInc + $NightsForQuery - 2; $SelectDates = mysql_query("SELECT * FROM BookingsCalendar WHERE AutoIncNo BETWEEN $AutoInc AND $AutoInc2"); while($row = mysql_fetch_array($SelectDates)) { $AutoIncNo = $row["AutoIncNo"]; $BookingDate = $row["BookingDate"]; $Status = $row["Status"]; if ($Status == 'booked') { $LastBookedDate = $BookingDate; $LastAutoIncNo = $AutoIncNo; $Handle = 1; } } // End - while($row = mysql_fetch_array($SelectDates)) { if ($Handle !== 1) {echo 'DATES AVAILABLE >> WRITE BOOKING CODE';} So if the handle is not equal to 1 its fine and they can book, but, if the dates arn't available (i.e, $Handle == 1) I need to check the closest available dates either side (before and after) the date they wanted where the Status is 'available' for the amount of nights they wish to stay... So I set out to establish the first available date in either direction and thts where I got stuck. Looking at it I'm sure you could run a while loop to find the next available block inside the code above, but not sure how. PHP Code: $FirstDateQuery = mysql_query("SELECT * FROM BookingsCalendar WHERE Status='available' AND AutoIncNo < $LastAutoIncNo ORDER BY AutoIncNo DESC LIMIT $NightsForQuery"); while($row = mysql_fetch_array($FirstDateQuery)) { $AutoIncNo = $row["AutoIncNo"]; $BookingDate = $row["BookingDate"]; $Status = $row["Status"]; echo $BookingDate . ' '; } Which works, but, it selects the previous 4 rows individually. So for example, if someone tries to book from 2013.06.01 but cant because its 'booked' for the next 4 days, the above script runs and brings up 2013.05.31 - 2013.05.30 - 2013.05.29 - 2013.05.28 as a result. But if one of those dates are booked it will skip it and give me the next one (selecting as it is the next 4 that meet the condition 'available') So if say 2013.05.29 was booked it would show 2013.05.31 - 2013.05.30 - 2013.05.28 - 2013.05.27 missing out the day which is booked. Now the thing is that we need the next 4 rows together (undivided/continuous/without breaks in the dates) which are 'available'. If you have a better more efficient way or can adapt what is already here, that would be grand... My brain hurts lol. Thank you, L-Plate
  17. sorry, yes, and im watching for the changes in phpmyadmin and the entries are made but without the changes i have made in the mysql_query. hmmm... scratchy heady
  18. hello there, thanks very much for the response. silly thing is its not the code which is the problem. it worked fine with the original code, all i added was 1 extra update in the query same as the others to corrispond with a new row i put into the table. thing is, if it were a mistake, like somehow i put the wrong value or missed a comma or something i could debug it. thing is, i changed one of the values which is represented by a variable with a string which is meant for a varchar entry and there was no difference. it seems like its being ignored by the engine as an attempt to inject incorrect values into the data base. i know the pages are ftp'ing ok because i echoed a string at the top of the page to confirm the change in the code. hmmm, very confusing stuff any ideas?
  19. [to the moderators, sorry, i dont know which section this actually belongs in] hi there all, im rewriting/updating/improving a site i wrote last year. i havent touched it since and it seem php has moved forward a few stages which is why i need to update bits around the site. anywayz, so im adding stuff to a query to update the table, i change it in the code, ftp the page sucessfuly etc.. but the new query is ignored by the MySql database or the newer PHP engine. i think its to protect against sql injection but im not sure. it makes sense and its a valuable security feature if that is it but is making testing impossible. would appreciate your help if you know how to get round it, or if i right even. thanks, phpl
  20. Thanks laff, couldnt find your link but I went with this which seems to cover most of them. $fileatt_type = "application/doc, application/txt, application/pdf, application/rtf, appl/text, application/vnd.msword, application/vnd.ms-word, application/winword, application/word,"; // File Type Not sure about rich text documents tho, It's seems like they dropped it from Win 7. Cheers mate, LP
  21. Hello one and all, Just a quick request here, I've written a script that sends an email with an attached file by the user. (docx, txt, pdf, doc, rtf) are the formats I have accepted. At the moment I'm sending them with the following... $fileatt_type = "application/pdf"; // File Type It works fine with all formats in older email clients, i.e, like yahoo before they updated the layout, but in the newer versions it's specific and if I try to send it this way it is always delivered as a .PDF and doesn't open if it is any of the other formats. It may sound silly but I've searched a fair bit for the other extensions or formats to include instead of the above code (maybe something like application/doc or something) but there doesn't seem to be a list. Can anyone point me in the right direction? Much obliged, PHP the learned.
  22. Hello everyone, Sorry if this has been answered but if it has I can't find it anywhere. So, from the begining then. Lets say I had a member table and in it I wanted to store what their top 3 interests are. Their$ row has all the usual things to identify them userID and password etc.. and I had a further 3 columns which were labled top3_1 top3_2 & top3_3 to put each of their interests in from a post form. If instead I wanted to store this data as a PHP Array instead (using 1 column instead of 3) is there a way to store it as readable data when you open the PHPmyadmin? At the moment all it says is array and when I call it back to the browser (say on a page where they could review and update their interests) it displays 'a' as top3_01 'r' as top3_02 and 'r' as top3_03 (in each putting what would be 'array' as it appears in the table if there were 5 results. Does anyone know what I mean? For example - If we had a form which collected the top 3 interests to put in a table called users, <form action="back_to_same_page_for_processing.php" method="post" enctype="multipart/form-data"> <input name="top3_01" type="text" value="enter interest number 1 here" /> <input name="top3_02" type="text" value="enter interest number 2 here" /> <input name="top3_03" type="text" value="enter interest number 3 here" /> <input type="submit" name="update_button" value=" Save and Update! " /> </form> // If my quick code example for this form is not correct dont worry its not the point im getting at And they put 'bowling' in top3_01, 'running' in top3_02 and 'diving' in top3_03 and we catch that on the same page with some PHP at the top --> if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' With me so far? If I had a table which had 3 columns (1 for each interest) I could put something like - include('connect_msql.php'); mysql_query("Select * FROM users WHERE id='$id' AND blah blah blah"); mysql_query("UPDATE users SET top3_01='$top3_01', top3_02='$top3_02', top3_03='$top3_03' WHERE id='$id'"); And hopefully if ive got it right, it will put them each in their own little column. Easy enough huh? But heres the thing, I want to put all these into an array to be stored in the 1 column (say called 'top3') and whats more have them clearly readable in PHPmyadmin and editable from there yet still be able to be called back an rendered on page when requested. Continuing the example then, assuming ive changed the table for the 'top3' column instead of individual colums, I could put something like this - if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' $top3_array = array($top3_01,$top3_02,$top3_03); include('connect_msql.php'); mysql_query("UPDATE members SET top3='$top3_array' WHERE id='$id' AND blah blah blah"); But it will appear in the column as 'Array' and when its called for using a query it will render the literal string. a r r in each field instead. Now I know you can use the 'serialize()' & 'unserialize()' funtcions but it makes the entry in the database practically unreadable. Is there a way to make it readable and editable without having to create a content management system? If so please let me know and I'll be your friend forever, lol, ok maybe not but I'd really appreciate the help anyways. The other thing is, If you can do this or something like it, how am I to add entries to that array to go back into the data base? I hope ive explained myself enough here, but if not say so and I'll have another go. Thanks very much people, L-PLate (P.s if I sort this out on my own ill post it all here)
×
×
  • 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.