PHP - I Need To Combine 5 Numbers In Sets Of 3 ...
i have an array with 5 numbers...
Code: [Select] $numbers = array(1 => 4; 2 => 26; 3 => 15; 4 => 36 5 => 9); I need a method to combine them in sets of three.. For example: 4, 26, 15 4, 26, 36 4, 26, 9 and so on ... Have ten possible combinations. Any idea or advice of how i could do this...? Similar TutorialsHi, I need to sort variables in groups of up to 15 and put it in an array. For example: $exstract['center_tabOpBody_0'] =5 $exstract['center_tabOpBody_1'] =6 $exstract['center_tabOpBody_2'] =8 $exstract['center_tabOpBody_3'] =1 Should yield: ARRAY( = center_tabOpBody_1,center_tabOpBody_2,center_tabOpBody_3 // <-----15 [1] = center_tabOpBody_0 //<----5 ) Is there some simple function do do the "efficiency" sort? Thanks, Vadim mysql_query("UPDATE mods SET version='$version' AND name='$title' AND descritpion='$description' AND lastupdate='$date' WHERE id='$id'"); I don't think I'm doing it correctly. :/ Hello everyone, I have created a widget with php which allows users to put on their webpage and displays some information. To display the widget I am creating a javascript code for users to put on their websites. The javascript has a source of php page like src="widget.php?id=123" When they put the code on their websites php file is executed and displays some texts which is read from a remote XML file. There is no problem up to this point. But while I am reading from this XML file, the texts which are displayed on users webpage, are not in good format becouse I am converting string texts to ISO_8859-9 charset with "iconc" function. If the charset of webpage is ISO-8859-9 text are displayed correctly but if it is not, text are not displayed as expected. In example if the webpage charset is set to UTF-8, characters become unreadable. If I know the charset of webpage I can then convert strings to that charset. But could not find a predifined function thats doing this. Any idea about this problem ? or any other solutions you advice for this problem ? Thank you... This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321612.0 Hello community, I am trying to create a login script, but in the HTTP Header it only sends the last cookie set. I first tried this code: $expire=time()+60*60*24; setcookie("gcg_user",$userid,$expire); setcookie("gcg_name",$username,$expire); setcookie("gcg_pass",$password,$expire); But it only set the gcg_pass cookie. Someone else suggested me to use header(): $expire=date(DATE_RFC822,time()+60*60*24); header('Set-Cookie: gcg_user="'.$userid.'"; expires='.$expire.';'); header('Set-Cookie: gcg_name="'.$username.'"; expires='.$expire.';',false); header('Set-Cookie: gcg_pass="'.$password.'"; expires='.$expire.';',false); But again it only sets the last cookie. The first code has been working fine on another server. Do I have to adjust anything in php.ini? Running XAMPP Lite: Quote ###### Apache Friends XAMPP Lite (Basis Package) version 1.7.3 ###### + Apache 2.2.14 (IPV6 enabled) ... + PHP 5.3.1 (PEAR) ... Any help on that? Thanks in Advance! I have had a thread here recently titled: Special Language characters doesn't display correctly. Now however, I have encountered a new problem with character sets, that I hope you can help me resolve! I find the concept of character sets quite confusing. When you are dealing with a database and want the content to be displayed on a web page, you obviously want it to be displayed correctly, and if you are not from an English speaking country, this could cause you some problems here and there due to international characters. As I have understood, one need to tell how the data (text) is stores in the database, how it is being interpreted (collation) and how it is being displayed on the web page.
Here is my situation:
One php page is displaying the content of a guestbook: show_content. This php file is divided into three parts: An include of a header.html file, a middle section displaying the content of the database and finally an include of a footer.html file to take care of the lower part of the page. Now, the header.html file does contain the script for a dropdown menu written in javascript:
header.html
<html> <head> <title>Guestbook</title> <meta http-equiv="Content-Language" content="da"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <LINK REL=stylesheet TYPE="text/css" HREF="generel/pop_style.css"> <LINK REL=stylesheet TYPE="text/css" HREF="generel/hoved.css"> </HEAD> <BODY leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 background="generel/univback.gif"> <script type="text/javascript" language="JavaScript1.2" src="generel/pop_core.js"></script> <script type="text/javascript" language="JavaScript1.2" src="generel/pop_data.js"></script> <script type="text/javascript" language="JavaScript1.2" src="generel/pop_events.js"></script> <!--etc .......The main page controlling this header: show_content.php <?php function handle_fatal_errors() { if (http_response_code() == 500) {echo 'A technical error ocurred.';} } register_shutdown_function('handle_fatal_errors'); ini_set('display_errors', 0); include("header.html"); include("settings.php"); header('Content-Type: text/html; charset=utf-8'); //etc ...The footer.html file doesn't really matter here, so I avoid it. Now the strange thing: When I execute the show_content.php file above, the content of the database (guestbook) display perfectly, but the International letters in the dropdown menu don't display properly. BUT if I out-comment the following line: header('Content-Type: text/html; charset=utf-8');in the show-content.php file it is the opposite way around!! Then the items in the dropdown menu display properly while the content of the guestbook don't! By the way: When I connect to the database to store items, I do it with the following code: $db = new PDO('mysql:host='.$server.';dbname='.$database.';charset=utf8mb4', $username, $password);If somebody have an idea for an explanation of this behavior, I will be happy to hear about it! To me all these character set issues seem rather overwhelming. Maybe one setting override the other or what? NB! I also read that the people around the developement of PHP temporarily gave up on Unicode support for a PHP 6.0 version ... Erik Edited by erikla, 31 July 2014 - 06:29 PM. I would like to use the mail function to send an email to users from a database. I would like to pupulate the message body with records from a different table using another query. anyone know how to do this? thanks I'm looking for a method to replace everything between brackets. The patterns that I'm looking for are defined: "/\[([2-9TJQKA][hdcs])\]/" The pattern inside the bracket could accur 2 or even 3 times inside the brackets. For example first occurance would be [Ac Kd], here I want to replace Ac into an imge and Kd too. Later in the text I will most of the time get 3 sets, instead of two: [Jc Td 9d]. The sets always consist of [2-9JQKA][hdcs] and also in this order. Another example: [2d 2s 2h], or [3s 4h 5c]. If I use the following function, it would not work optimally because some texts do contain some of those sets which should not be converted, ONLY the sets between the brackets: $haystack = setReplace($haystack); function setReplace($haystack) { $array = array("2s", "2h", "2d", "2c", "3s", "3h", "3d", "3c", "4s", "4h", "4d", "4c", "5s", "5h", "5d", "5c", "6s", "6h", "6d", "6c", "7s", "7h", "7d", "7c", "8s", "8h", "8d", "8c", "9s", "9h", "9d", "9c", "Ts", "Th", "Td", "Tc", "Js", "Jh", "Jd", "Jc", "Qs", "Qh", "Qd", "Qc", "Ks", "Kh", "Kd", "Kc", "As", "Ah", "Ad", "Ac"); for($i=0;$i < count($array);$i++) { $result = str_replace($array[$i], "<img src=\"/images/".$code[$i].".png\">",$haystack); } return $result; }Any ideas? Edited by dde, 20 January 2015 - 10:21 AM. Ill spare you the full code because I don't think you'll need it to answer this, but I have code where an array called $days1 is being created. It's working fine as is to bring back 1 set of data, but I want to keep adding to the array for however many sets of data there are in the "while" statement. So my question is how do I write this so that ALL sets of data brought back by MySQL (whether it's 1 row or 50) keep getting added to the array, rather than just having one set of info in my array? I feel like I need to put "$days1 = array(" before the WHILE statement and then put the closing ")" after all the loops are done, but that didn't work. Can anyone help me out here? (assuming it makes sense )... Code: [Select] while ($hunches = mysql_fetch_array($gethunches)) { $days1 = array( $hunches['day']=>array(NULL,NULL,'<span class="red">' . $hunches['firstname'] . " " . $hunches['lastname'] . "-" . $hunches['dob'] . "--" . $hunches['sex'] . '</span>'), ); } I have this code working fine (thanks to Thorpe). FYI, this code is getting info for each day and putting that info into the array and then later on a calendar is generated and the data gathered here is placed onto each specific day. This is working EXCEPT when there are MULTIPLE data sets on the SAME day. In those cases, it's just displaying the first data set. In other words, if $hunches['day'] = 3 and there is just one data set with that date, it will display that info on the calendar fine. But if there are five data sets with $hunches['day'] = 3, then it only displays the first one. I need it to display all data sets, so any clue how I could alter this code to do that? Code: [Select] $sql = "SELECT *, DATE_FORMAT(`dob`, '%e') AS day FROM hunches WHERE poolid = '{$_GET['poolid']}' AND (DATE_FORMAT(`dob`,'%m')) = " . $month1 . " ORDER BY day"; $gethunches = mysql_query($sql, $connection); if (!$gethunches) { die("Database query failed: " . mysql_error()); } else { while ($hunches = mysql_fetch_array($gethunches)) { $days1[$hunches['day']] = array(NULL,NULL,'<span class="red">' . $hunches['firstname'] . '</span>'); } } Here is a further explanation... Say $hunches['day'] = 5 and there are four data sets for that day (with respective firstnames of Bob, Joe, Jim and Tony). I would essentially need this to happen in the code... Code: [Select] $days1[$hunches['day']/*which would be 5 in this example*/] = array(NULL,NULL,'<span class="red">' . $hunches['firstname'] . '</span><br> <span class="red">' . $hunches['firstname'] . '</span><br> <span class="red">' . $hunches['firstname'] . '</span><br> <span class="red">' . $hunches['firstname'] . '</span>'); And that would then output... Bob Joe Jim Tony ...in the 5th day box on the calendar. Right now, I'm just getting... Bob I fear this is very complicated to do but holding out hope that there is some relatively easy way to make this work. Hi, I need some help getting my head around arrays. I have a basket of fruit: $basket=("Apple","$Orange","$Banana","$Banana","$Peach","$Apple","$Banana","$Orange","$Apple"); I want to distribute and share this basket of fruit into bowls, such that each bowl contains the following: $bowl=("$Apple",$Orange,"$Banana","$Banana") ie. One Apple, One Orange & Two Bananas. I can't seem to figure out how to do it. Thanks in advance. Hi i have a form which display the date in the format that i want which is m/d/yyyy but then when i try update it sets the date back to 01/01/1970 help please this how the update script looks like <?php //Get the key field to be amended $news_id = $_GET['news_id']; $news_date = date('Y-m-d', strtotime($_GET['new_date'])); $subject = $_GET['subject']; $news_artical = $_GET['news_artical']; // check if there were any errors // check if there were any errors //$news_date = STR_TO_DATE('$news_date','%Y/%m/%d'); $query = "UPDATE news SET news_date = '$news_date', subject='$subject', news_artical='$news_artical' WHERE news_id = '$news_id'"; mysql_query($query) or die(mysql_error()); // execute query print "<p>The following records has been updated: </p>"; $result = mysql_query($query) ; //if there was a problem - get the error message and go back if (!$result) { echo "There were errors :<br>". mysql_error(); } else //OK, then the insertion was successful { //Create a new query to display the new row in a table $query = "SELECT news_id, news_date, subject, news_artical, DATE_FORMAT(news_date, '%d/%m/%Y') as new_date FROM news WHERE news_id = '$news_id' "; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo "<table cellpadding=10 border=1>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$row["news_id"]."</td>"; echo "<td><strong>" .$row["new_date"]."</strong></td>"; echo "<td><strong>".$row["subject"]."</strong></td>"; echo "<td width='55%'>".$row["news_artical"]."</td>"; echo "</tr>"; } //End while echo "</table>"; } //End Else insertion successful //End else successful Amendment ?> Although I am deciding on the best route to go on this, I was hoping for any feedback or ideas on the best and simplest approach to the below problem: Here is my table structu old_code_1 old_code_2 new_code_1 new_code_2 prod_code_1 prod_code_2 Each of the following fields has 5 digits e.g. 00045, 12654, etc. What I need to achieve is this: Concatenate each set (of the 3 sets above) data into one variable e.g. old_code_1 + old_code_2 = 0004512654. So old_code_1 & old_code_2 would become a combined data and the same for the othe 2 sets. Then. Once concatenated, I need to compa prod_code_1+prod_code_2 with old_code_1+old_code_2 and replace prod_code_1+prod_code_2 with new_code_1+new_code_2 where matches are found. The new_code_1 & 2 are in the same row as the old_code 1 & 2. So the data is in alignment that way for comparison. Thanks for any insight or suggestions on how to make this happen in the simplest form possible. I need to have several sets of radio buttons, each of which will be used to assess criteria, e.g. endurance, strength, posture, etc. I've made a function, as follows: Code: [Select] <?php function makeRadio($min, $max, $lbl) { echo "<div class='inline_label'>".$lbl."</div>"; for ($i = $min; $i <= $max; $i++) { echo "<input type='radio' name='".$lbl."' value='".$i."' id='".$lbl.$i."_".($i-1)."'"; if(isset($_POST[$lbl])) { echo " checked='checked'"; } echo "/>".$i." "; } echo "<br />"; } I'm calling the function like this: Code: [Select] <form id="form1" name="form1" method="post" action="" > <?php makeRadio(1,10, 'Endurance'); makeRadio(1,10, 'Strength') ?> <p><input type="submit" name="submit" id="submit" value="Submit" /></p> </form> On form submission, however, I can't get the buttons to be sticky? Where am I going wrong in my function code? TIA Hi guys, im currently querying my database and if ($row) im including a file. But i would like to make it so if ($row) or a session variable is active, to include the file. I have tried using || but ive only ever used that for regular variables and I cant get it working in the way i want. so at the moment i have Code: [Select] if ($row) ( require 'myfile'; and i would like to add || $_SESSION['email'] is active. im guessing i would use isset, but i just cannot get it working. Hello I have this query and it is working well: Code: [Select] $data = mysql_query(" SELECT `title`, `body`, 'condoms_en' as REF FROM `condoms_en` UNION SELECT `title`, `body`, 'discr_en' as REF FROM `discr_en` UNION SELECT `title`, `body`, 'diseases_en' as REF FROM `diseases_en` UNION SELECT `title`, `body`, 'express_en' as REF FROM `express_en` UNION SELECT `title`, `body`, 'gender_en' as REF FROM `gender_en` UNION SELECT `title`, `body`, 'get_informed_en' as REF FROM `get_informed_en` UNION SELECT `title`, `body`, 'get_tested_en' as REF FROM `get_tested_en` UNION SELECT `title`, `body`, 'newly_en' as REF FROM `newly_en` UNION SELECT `title`, `body`, 'news_hiv_en' as REF FROM `news_hiv_en` UNION SELECT `title`, `body`, 'nutrition_en' as REF FROM `nutrition_en` UNION SELECT `title`, `body`, 'phdp_en' as REF FROM `phdp_en` UNION SELECT `title`, `body`, 'press' as REF FROM `press` UNION SELECT `title`, `body`, 'r_o_en' as REF FROM `r_o_en` UNION SELECT `title`, `body`, 'stats_en' as REF FROM `stats_en` UNION SELECT `title`, `body`, 'stigma_en' as REF FROM `stigma_en` UNION SELECT `title`, `body`, 'think_news_en' as REF FROM `think_news_en` UNION SELECT `title`, `body`, 'think_reports' as REF FROM `think_reports` UNION SELECT `title`, `body`, 'treatment_en' as REF FROM `treatment_en` where`title` like '%$kw%' OR `body` like '%$kw%'") or die(mysql_error()); $rows = mysql_num_rows($data); I need to add to the same query this part: Code: [Select] SELECT `cont`, 'about_us_en' as REF FROM `about_us_en` UNION SELECT `que`,`ans`, 'faq_en' as REF FROM `faq_en` UNION SELECT `orga`, `lnk`, 'links_en' as REF FROM `links_en` UNION SELECT `title`, `desc`, 'publications' as REF FROM `publications` IF I add this part as is, I get an error saying that the select has different columns. Please Help and how do I modify the where if they are combined?! Thank you Gud Eve peeps! So i have 2 variable strings: Code: [Select] $variable1 = item, item, item; $variable2 = number, number, number; I need to make this 2 variables into 1 array being variable 1 as a key value and variable 2 as a variable.. and i tried combining them using: Code: [Select] $array = array_combine($variable1, $variable2); the problem is some item name are the same so it just overwrites the other so instead of giving me this: Array ([item] => number, [item] => number, [item =>number]) it gives me this: Array ([item =>number]) I really need them to be complete because i will loop each key and value to be inserted to a new row in my db.. thanks again for the help! I know this involves MySQL, but it's mostly PHP, so I figured it should go here, forgive me if I posted in the wrong section, though. Anyway! Let's get down to it. I'd like to combine these two scripts (below). I want the questionnaire script to be a signup requirement in the signup script, and I want it to log the questionnaire into my MySQL database as usual, then prompt the user with a successful sign up. I'm still really new to PHP and I'm just testing to see if this'll work. How would I go about doing this? Thanks a LOT guys. Questionnai <?php // Start the session require_once('startsession.php'); // Insert the page header $page_title = 'Questionnaire'; require_once('header.php'); require_once('appvars.php'); require_once('connectvars.php'); // Make sure the user is logged in before going any further. if (!isset($_SESSION['user_id'])) { echo '<p class="login">Please <a href="login.php">log in</a> to access this page.</p>'; exit(); } // Show the navigation menu require_once('navmenu.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // If this user has never answered the questionnaire, insert empty responses into the database $query = "SELECT * FROM mismatch_response WHERE user_id = '" . $_SESSION['user_id'] . "'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 0) { // First grab the list of topic IDs from the topic table $query = "SELECT topic_id FROM mismatch_topic ORDER BY category_id, topic_id"; $data = mysqli_query($dbc, $query); $topicIDs = array(); while ($row = mysqli_fetch_array($data)) { array_push($topicIDs, $row['topic_id']); } // Insert empty response rows into the response table, one per topic foreach ($topicIDs as $topic_id) { $query = "INSERT INTO mismatch_response (user_id, topic_id) VALUES ('" . $_SESSION['user_id']. "', '$topic_id')"; mysqli_query($dbc, $query); } } // If the questionnaire form has been submitted, write the form responses to the database if (isset($_POST['submit'])) { // Write the questionnaire response rows to the response table foreach ($_POST as $response_id => $response) { $query = "UPDATE mismatch_response SET response = '$response' WHERE response_id = '$response_id'"; mysqli_query($dbc, $query); } echo '<p>Your responses have been saved.</p>'; } // Grab the response data from the database to generate the form $query = "SELECT mr.response_id, mr.topic_id, mr.response, " . "mt.name AS topic_name, mc.name AS category_name " . "FROM mismatch_response AS mr " . "INNER JOIN mismatch_topic AS mt USING (topic_id) " . "INNER JOIN mismatch_category AS mc USING (category_id) " . "WHERE mr.user_id = '". $_SESSION['user_id'] . "'"; $data = mysqli_query ($dbc, $query); $responses = array(); while ($row = mysqli_fetch_array($data)) { array_push($responses, $row); } mysqli_close($dbc); // Generate the questionnaire form by looping through the response array echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<p>How do you feel about each topic?</p>'; $category = $responses[0]['category_name']; echo '<fieldset><legend>' . $responses[0]['category_name'] . '</legend>'; foreach ($responses as $response) { // Only start a new fieldset if the category has changed if ($category != $response['category_name']) { $category = $response['category_name']; echo '</fieldset><fieldset><legend>' . $response['category_name'] . '</legend>'; } // Display the topic form field echo '<label ' . ($response['response'] == NULL ? 'class="error"' : '') . ' for="' . $response['response_id'] . '">' . $response['topic_name'] . ':</label>'; echo '<input type="radio" id="' . $response['response_id'] . '" name="' . $response['response_id'] . '" value="1" ' . ($response['response'] == 1 ? 'checked="checked"' : '') . ' />Love '; echo '<input type="radio" id="' . $response['response_id'] . '" name="' . $response['response_id'] . '" value="2" ' . ($response['response'] == 2 ? 'checked="checked"' : '') . ' />Hate<br />'; } echo '</fieldset>'; echo '<input type="submit" value="Save Questionnaire" name="submit" />'; echo '</form>'; // Insert the page footer require_once('footer.php'); ?> Signup: <?php // Insert the page header $page_title = 'Sign Up'; require_once('header.php'); require_once('appvars.php'); require_once('connectvars.php'); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { // Grab the profile data from the POST $username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2'])); if (!empty($username) && !empty($password1) && !empty($password2) && ($password1 == $password2)) { // Make sure someone isn't already registered using this username $query = "SELECT * FROM mismatch_user WHERE username = '$username'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 0) { // The username is unique, so insert the data into the database $query = "INSERT INTO mismatch_user (username, password, join_date) VALUES ('$username', SHA('$password1'), NOW())"; mysqli_query($dbc, $query); // Confirm success with the user echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>'; mysqli_close($dbc); exit(); } else { // An account already exists for this username, so display an error message echo '<p class="error">An account already exists for this username. Please use a different address.</p>'; $username = ""; } } else { echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>'; } } mysqli_close($dbc); ?> <p>Please enter your username and desired password to sign up to Mismatch.</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>Registration Info</legend> <label for="username">Username:</label> <input type="text" id="username" name="username" value="<?php if (!empty($username)) echo $username; ?>" /><br /> <label for="password1">Password:</label> <input type="password" id="password1" name="password1" /><br /> <label for="password2">Password (retype):</label> <input type="password" id="password2" name="password2" /><br /> </fieldset> <input type="submit" value="Sign Up" name="submit" /> </form> <?php // Insert the page footer require_once('footer.php'); ?> And here are the pastebins in case you prefer those: http://pastebin.com/pTXGSMT9 - Questionnaire http://pastebin.com/28jZhYyY - Signup Thanks! I have a small form which executes a php file, and the executable php file. is there anyway to have it just using the 1 php file? form code: Code: [Select] <form enctype="multipart/form-data" action="upload-exec.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form> uploader.php Code: [Select] <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> i did try using: Code: [Select] if (isset($_POST['submit'])) { with no luck. Many thanks Hi Everyone, I am trying to add on to this mobile detection script that I have been using (quite nicely I might add) from http://detectmobilebrowsers.com/ Code: [Select] <?php // check for mobile browser $useragent = $_SERVER['HTTP_USER_AGENT']; if(preg_match('/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) // redirect if mobile browser header('Location: http://www.example.com/mobile/'); ?> I would like to use/combine some sort of redirect link for users who are redirected to the mobile site to be ridirected back to the full site and vice versa. I wrote a quick $_GET example below, but would rather use $_SESSIONS if possible to make it more transparent/invisible. My question is how best to combine the code above with the code below and get it to work? Code: [Select] <a href="http://www.example.com/?mobile">View Mobile Site</a> <a href="http://www.example.com/?full">View Full Site</a> <?php if ($_GET['mobile']) { $variable = true; } if ($_GET['full']) { $variable = false; } ?> Any help, suggestions, or examples would be appreciated. Thanks in advance, kaiman |