PHP - 100% Width Based On Orientation
Hi Guys
I am using media queries to set a different CSS if a mobile device. I am using 100% width on certain containers but the styling is using 100% based on the landscape orientation and not whichever way the device is being displayed.
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
.slicknav_menu{
visibility:visible;
Similar TutorialsI've added a CSS class to the main menu of a Wordpress site and wish to remove the class if the browser width drops below a certain number. I've tried a number of different approaches but none has worked.
Some examples:
$(document).ready(function() { I have instantiated a object and the constructor has an other object added the issue arises when I extent the first object how do I access the object in the variable. below is a stripped down example. I want accessfoo to access class a method foo that is stored in a var in class b is this possible. Code: [Select] class a { private function foo(){ return "hello word"; } } $a = new a() class b { private $obj; public function __construct ($obj){ $this->obj= $obj; } } class c extends b{ private function accessfoo(){ $this->obj ????????????? } $c = new class($a) Hello,
I have a pretty basic two panel design, no code yet but it is pretty straight forward
What I'm concerned about is how a website can react to an orientation change, not simply be re sizing but by relocating items.
So in portrait mode, I have panel a, the top half say 50%, and panel b, 50% bottom half
I rotate it (the phone) to the left of my perspective (viewer) and the top panel goes to the left, and the bottom panel goes to the right.
In the meantime some scrolling animation is in play and the direction of the scroll changes, from sideways to up and down...
Is that possible without refreshing the page?
Edited by greenace92, 04 December 2014 - 04:53 AM. Hi, I want to create a function that reads the exif orientation data of an image and rotates it as required - needs to run before before the resize function here, I'm using GD library if that is relevant: function resize_gd($sourceFileName, $folder, $destinationFileName, $newWidth, $newHeight, $keepProportion) { $newWidth = (int)$newWidth; $newHeight = (int)$newHeight; if (!$this->gdInfo >= 1 || !$this->checkGdFileType($sourceFileName)) { return false; } $img = &$this->getImg($sourceFileName); if ($this->hasError()) { return false; } $srcWidth = ImageSX($img); $srcHeight = ImageSY($img); if ( $keepProportion && ($newWidth != 0 && $srcWidth<$newWidth) && ($newHeight!=0 && $srcHeight<$newHeight) ) { if ($sourceFileName != $folder . $destinationFileName) { @copy($sourceFileName, $folder . $destinationFileName); } return true; } if ($keepProportion == true) { if ($newWidth != 0 && $newHeight != 0) { $ratioWidth = $srcWidth/$newWidth; $ratioHeight = $srcHeight/$newHeight; if ($ratioWidth < $ratioHeight) { $destWidth = $srcWidth/$ratioHeight; $destHeight = $newHeight; } else { $destWidth = $newWidth; $destHeight = $srcHeight/$ratioWidth; } } else { if ($newWidth != 0) { $ratioWidth = $srcWidth/$newWidth; $destWidth = $newWidth; $destHeight = $srcHeight/$ratioWidth; } else if ($newHeight != 0) { $ratioHeight = $srcHeight/$newHeight; $destHeight = $newHeight; $destWidth = $srcWidth/$ratioHeight; } else { $destWidth = $srcWidth; $destHeight = $srcHeight; } } } else { $destWidth = $newWidth; $destHeight = $newHeight; } $destWidth = round($destWidth); $destHeight = round($destHeight); if ($destWidth < 1) $destWidth = 1; if ($destHeight < 1) $destHeight = 1; $destImage = &$this->getImageCreate($destWidth, $destHeight);Edited June 7, 2019 by mcfc4heatons Hello. I want to make a web-based rpg with mysql and php but need alot of help, I tryed once and failed. Please msn me: cginbarrhaven@hotmail.com I need LOTS of help. Im stuck! Zeroth I have a page where I want a success and a fail response. It's a contact page so, if they fill in all that's required, and send, a success "message" will pop up but if they send but for some reason, it fails, to display a fail "message". What it does right now is the fail and success are constantly visible regardless. So how do I make it display the corresponding message accordingly? *Also how am I to make the text within the boxes invisible ? But that's lower priority Hi all, Relitively new to PHP but am trying to code a site that dynamically creates urls using Joomla CMS. Basically I'd like a div to show on pages' url starts /component/.... but hide it if not. The urls of the pages on which the div is to be hidden start /index.php?. I've tried Code: [Select] <?php if (strpos($_SERVER['REQUEST_URI'], 'component') > 0) { echo '<div id=\"stuffdiv\">stuff</script></div>';} ?> only issue is... its always fasle hence the div never shows. If i replace > with >= its always true, and appears on all pages, even those not containing 'component'... Can someone tell me if this should work or if Im being really stupid? Thanks in advance! Tom I have this array: Code: [Select] Array ( [jan] => 2 [feb] => 1 [mar] => 2 [apr] => 1 ) ..and I want to return: Code: [Select] Array ('jan', 'mar') As in, find the 2 elements with the highest count and put them in an array. What is the simplest way to achieve this? hi everyone. i need to figure out how to display one tr or another based on if N/A appears in one of the TR's. if i use: 'if ($result['NoChargeFile'] = 'N/A')' it repeats N/A for all rows. if i use: 'if ($result['NoChargeFile'] = N/A)' only the TotalFees TR is displays. What i need to do is display the TOTALFEES if the NOCHARGEFILE is not N/A. If NOCHARGEFILE is N/A, display N/A instead of the TOTALFEES. Any ideas how to fix this issue? thanks. Code: [Select] <?php echo "<table width='100%' border='0' cellpadding='1'>"; $string = $string."$pages->limit"; $query = mysql_query($string) or die (mysql_error()); $result = mysql_fetch_array($query); if($result==true) { do { echo "<tr>"; echo '<td nowrap>' . $result['CompanyName'] . '</td>'; echo '<td nowrap>' . $result['CompanyReferenceNumber'] . '</td>'; if ($result['NoChargeFile'] = 'N/A') { echo '<td nowrap>' . $result['NoChargeFile'] . '</td>'; } else { echo '<td nowrap>' . $result['TotalFees'] . '</td>'; } echo '<td nowrap>' . $result['DateRecorded'] . '</td>'; echo '<td nowrap>' . $result['DateClosed'] . '</td>'; echo "</tr>"; } while($result = mysql_fetch_array($query)); } // close table> echo "</table><hr>"; ?> I figured it out. i need == not =. Hi, I need to create a secure API at work so that 2 systems can interact with each other and request data (json format). I need to use an API key for this but don't want to use an API key stored in a database, what is the best way to go about this? I would like to use some sort of encryption algorithm and a white list of a few values to validate against once decrypted, is this safe and are there any algorithms I can use to generate my keys and white list? Hello folks. I have a system showing stock of products. Now I want to colorize the value based on how much it is. For example 0 is red and then green is 10 000 and up. So the range should be like a smooth gradient. What's the algorithm? This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=359538.0 Hi, I have a page where users can add some text and additionally images. This is done through a textbox and NicEditor. Users are able to add images with any size, by either uploading it or usea URL. The problem occurs when they add a image wider than 560px, because then it ruins my lay out. This is why i want to add style="max-width:560px;" at the end of all image tags. So for example Code: [Select] <img src="http://images.com/image.jpg" style="max-width:560px;"> If made the following code but this only works when a user adds just one image, i need it to work also when there are multiple images. Code: [Select] <?php $img = '<img src="http://images.com/image.jpg">'; $imgstart = strpos($img,'<img'); // get position of <img if($imgpstart !== false) { $imgend = strpos($img,'>'); // get position of > $width = ' style="max-width:560px;">'; $img= substr_replace($img, $width, $imgend, 1); // replace > with $width } echo $img; ?> This may not be the safest and best solution so i'd like some help with a function which finds all images in a string and give them a max-width. thanks! I have htaccess file from which I am calling htpasswd. Currently its ask for authentication from everyone. I want it IP based or Domain based so that a user requesting from specific IP may not have to go through http authentication. Some domain calling the web pages in background like paypal OR google checkout can access the page without http authentication. Is it possible ? content of htaccess file is given below. AuthUserFile /var/www/web/.htpasswd AuthName "Authorization Required" AuthType Basic <Limit GET POST> require user username </Limit> Hi there,
Is it possible to redirect to another URL based on the cookie that has already loaded on the page?
For example,
If cookie = cookie_name then redirect to http://www.google.com
Thanks!
I know something is wrong but dunno how to fix it. My intention is to lock user based on ip after 3 unsuccessful attempts. Its incrementing the login count but after 3 attempts, I just can't figure out how to lock the user and reset the value after some time. I'd like a pointer towards the right/best thing to do should my code not be worthy. Thanks and heres my code: <?php $user_ip = $_SERVER['REMOTE_ADDR']; $table_name = "loginattempts"; $query = "SELECT attempts FROM $table_name WHERE user_ip = '$user_ip'"; $result = mysql_query($query) or die("Invalid Login"); while($row = mysql_fetch_array($result)){ $count = $row['attempts']; } if($count == 3){ echo("Your login attempt is completed"); }else{ $insert = "INSERT INTO $table_name WHERE user_ip = '$user_ip'"; $result = mysql_query($insert); $update = "UPDATE $table_name SET attempts = attempts + 1 WHERE user_ip = '$user_ip'"; $result = mysql_query($update); } $update = "UPDATE $table_name SET attempts = 0 WHERE lastlogin - NOW() = '60000'"; $result = mysql_query($update); ?> Hello, I have started a DB for simple web based inventory system, I have only dabbled in PHP before 6 weeks ago, within the last 6 weeks with some help and going through countless tutorials and asking questions when I need. At this time setup an insert, delete and update function for this db and are working perfectly, now what I need to know is there a way to display something like 'in stock' and 'out of stock' using php, based on the value of the quantity in my db next to the item in a table?
Example : when the table is generated it will display:
| Part number | Description | Stock | (normally Stock would show the quantity of each part, I just wish to
|10-1111 | Some info | In Stock | display In or out os stock)
|10-1112 | Some Info | Out of Stock |
I the only code I have is the tables and just not sure what to do next to get the results I have described above. So I will include the table code I have and see where we can go from there. Or if you have some webs site that I can read through that will be great as well as long as it can give me basic instruction on how to do this.
Reminder, I am self taught and still learning.
<?php $con = mysqli_connect("localhost","user","pass","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20"); echo "<table border='1'> <tr> <th>ID</th> <th>Part number</th> <th>description</th> <th>location</th> <th>Quantity</th> </tr>"; while ($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['amp20ptid'] . "</td>"; echo "<td>" . $row['partnum'] . "</td>"; echo "<td>" . $row['description'] . "</td>"; echo "<td>" . $row['location'] . "</td>"; echo "<td>" . $row['quantity'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); } ?> Edited by Thunder_Wolf, 22 October 2014 - 11:16 AM. Hi
I have a form that has a drop-down with a few to choose from, unfortunately I don't get results for some due to the query involved.
Some need the AND channel LIKE '%$channel%'"; and some don't and therefore will not get desired results. So I would like to run two queries one with and one without.
$query = "SELECT * FROM asterisk_cdr WHERE calldate BETWEEN '$calldate' AND '$calldate2' AND clid LIKE '%$clid%' AND channel LIKE '%$channel%'";
Thanks
Hi guys, PHP advanced amateur and PHPFreaks newbie here. I have a problem with some code I've written. What the code is supposed to do, is take in 15 records in a single MySQL table column, and then print them out in a format like this: 1 2 3 4 5 6 7 8 9 so on so on. Here is the page in question: http://robbieduggan.com/strawberry-interactive/portfolio-web-design.php Now the problem is, you can see 14 images there, but it seems to be negating the first one. Its always whatever row 0 is, because if I change the SORT BY attrabute in the code below, it's a different one that is missing. Here is my code to get the data: mysql_select_db($database_strawberry, $strawberry); $query_rsProjects = "SELECT page_unique_identity, clean_title, thumbnail FROM tblprojects ORDER BY `timestamp` DESC"; $rsProjects = mysql_query($query_rsProjects, $strawberry) or die(mysql_error()); $row_rsProjects = mysql_fetch_assoc($rsProjects); $totalRows_rsProjects = mysql_num_rows($rsProjects); And here is the code to create the table: echo "<table width='100%' border='0' cellspacing='5' cellpadding='5'>"; for($i = 0; $i < $totalRows_rsProjects; $i++) { $row = mysql_fetch_array($rsProjects); if($i % $columns == 0) { echo "<tr>"; } echo "<td>"; if($row['page_unique_identity'] != NULL){ echo "<a href='website-details.php?project=".$row['page_unique_identity']."'><img src='portfolio/".$row['thumbnail']."' alt=".$row['clean_title']." width='267' height='162' /></a>"; } echo "</td>"; if(($i % $columns) == ($columns - 1) || ($i + 1) == $totalRows_rsProjects) { echo "</tr>"; } } Thanks in advance for any help Hello everyone, here is my problem. I am working for someone that would like users to be able to create a Trial Account on their website. This trial account is to be used for 24 hours, once the 24 hours is completed they can no longer login/use that account. Everything about the Trial Account is completed, other then the account timer. I am at a loss on how to get this part done. I was thinking that I would use the MySQL commands, GETDATE() and DATEADD(), to get the date and time that the account was created and using the DATEADD() command I would add 24 hours to the GETDATE() value. Then if the user logs into at a date past the DATEADD() value the Users Account type is switched to 3(This means that the account has been disabled) and then is directed to the Logout page, which then redirects him back to the homepage. After this point, the user can no longer login due to the code preventing any user with an account type of 3 to login. The problem is that I am unaware how to incorporate the GETDATE() and DATEADD() functions into my PHP code. Would anyone be able to explain how I can get this done, or suggest a better method of inputting a starting time and ending time for the account? Thank You for any/all help. |