PHP - Sql Limits Not Working - Anything Wrong With Php ?
My sql limits are not working. In "select * from state order by state limit 18,36", state is not limiting till 36 but goes till 54 and prints it completely.My sql statement seems to be right. Is there any problem with my php ? When i debug my $check = 36 but it should be 18 ($check is just the variable to show how many values it is printing). Can someone please point me my mistake ?
Code: [Select] <table> <tr> <td> <?php $sql = "select * from state order by state limit 0,18"; $dat = mysql_query($sql); while($row = mysql_fetch_array($dat)) { $state=$row['state']; ?> <p><span> • </span> <a href="<?php echo $state; ?>-1.html"><strong><?php echo $state; ?></strong></a> <?php } ?> </p> </td> <td> <?php $sql = "select * from state order by state limit 18,36"; $check = 0; // used this to check $dat = mysql_query($sql); while($row = mysql_fetch_array($dat)) { $check++; // incrementing this value after each display $state=$row['state']; ?> <p><span> • </span> <a href="<?php echo $state; ?>-1.html"><strong><?php echo $state; ?></strong></a> <?php } ?> </td> </tr> </table> Similar TutorialsHello dears, I've tried to use htmlspecialchars or htmlentities but both no longer work ! Example1 : Code: [Select] <?php $new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); echo $new; ?> Output should <a href='test'>Test</a> Code: [Select] <?php $str = "A 'quote' is <b>bold</b>"; echo htmlentities($str); ?> Output should A 'quote' is <b>bold</b> But it isn't working ? what is wrong ? I'm having a problem with removing duplicates values in an array. seems like array_unique wont accept arrays bigger then 5084 also i tried $stargate_address_array= array_keys(array_flip($stargate_address_array)); $stargate_address_array= array_keys(array_count_values($stargate_address_array)); if i count the array before array_unique i get an array account of 600,000 but soon as it hits unique array its count is only 5084. anyone know how to get around this? function stargate_address_check() { $map_x = 200; $map_y = 200; $stars_per_sector = 15; $star_amount = $map_x * $map_y * $stars_per_sector; $stargate_address_array = ''; $create_address_array = 0; while ($create_address_array < $star_amount) { // creates a huge array of address's $new_address = stargate_address_generator(); $stargate_address_array[] = $new_address; ++$create_address_array; } // removes any duplicate address $stargate_address_arrays = array_unique($stargate_address_array); $count = count($stargate_address_arrays); return $count; } echo stargate_address_check(); the function im using to generate the values inside the array // creates a stargate address function stargate_address_generator() { $chevron1 = rand(1,38); $chevron2 = rand(1,38); while ($chevron1 == $chevron2) { $chevron2 = rand(1,38); } $chevron3 = rand(1,38); while ($chevron3 == $chevron1 || $chevron3 == $chevron2) { $chevron3 = rand(1,38); } $chevron4 = rand(1,38); while ($chevron4 == $chevron1 || $chevron4 == $chevron2 || $chevron4 == $chevron3) {$chevron4 = rand(1,38);} $chevron5 = rand(1,38); while ($chevron5 == $chevron1 || $chevron5 == $chevron2 || $chevron5 == $chevron3 || $chevron5 == $chevron4) {$chevron5 = rand(1,38); } $chevron6 = rand(1,38); while ($chevron6 == $chevron1 || $chevron6 == $chevron2 || $chevron6 == $chevron3 || $chevron6 == $chevron4 || $chevron6 == $chevron5) { $chevron6 = rand(1,38); } $stargate_address = "$chevron1-$chevron2-$chevron3-$chevron4-$chevron5-$chevron6"; return $stargate_address; } what I've done and since undone, because it wasn't working and cant show you because i use notepad. im trying to add values in arrays together it happens the wrong way tho instayed of adding the 2 arrays togeather it adds each value of the one array togeather like this =>27 [1] =>9 [2] =>9 [0] =>3 [1] =>1 [2] =>1 when what i really want is =>10 [1] =>10 [2] =>10 [0] =>1 [1] =>1 [2] =>1 (the ones are added to the nines) thank you for your time $i=1; $g=1; foreach($Mdarray as $MD1) { foreach($MD1 as $MD2) { $MD3[$g][$i] = explode("|" , $MD2); $i++; } $i=1; $g++; } print_r($MD3); print_r($MD3) returns (just alot of numbers nothing of real significant) Quote ( [1] => Array ( [1] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) [2] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) ) [2] => Array ( [1] => Array ( => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 1 [7] => 1 [8] => 1 [9] => 1 [10] => 1 [11] => 1 [12] => 1 [13] => 1 ) [2] => Array ( => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 1 [7] => 1 [8] => 1 [9] => 1 [10] => 1 [11] => 1 [12] => 1 [13] => 1 ) ) [3] => Array ( [1] => Array ( => 100 [1] => 100 [2] => 100 [3] => 100 [4] => 100 [5] => 100 [6] => 100 [7] => 100 [8] => 100 [9] => 100 [10] => 100 [11] => 100 [12] => 100 [13] => 100 ) [2] => Array ( => 100 [1] => 100 [2] => 100 [3] => 100 [4] => 100 [5] => 100 [6] => 100 [7] => 100 [8] => 100 [9] => 100 [10] => 100 [11] => 100 [12] => 100 [13] => 100 ) ) [4] => Array ( [1] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) [2] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) ) [5] => Array ( [1] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) [2] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) ) [6] => Array ( [1] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) [2] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) ) [7] => Array ( [1] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) [2] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) ) [8] => Array ( [1] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) [2] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) ) [9] => Array ( [1] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) [2] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) ) [10] => Array ( [1] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) [2] => Array ( => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) ) [11] => Array ( [1] => Array ( => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 1 [7] => 1 [8] => 1 [9] => 1 [10] => 1 [11] => 1 [12] => 1 [13] => 1 ) [2] => Array ( => 9 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 [13] => 0 ) ) ) im trying to create withdraw page Code: [Select] <?php $query=mysql_query("SELECT * FROM users WHERE login='$data->login'")or die(mysql_error()); $row = mysql_fetch_array($query); $moneycount="5000"; $count=$row['coins']; if(isset($_POST['send'])) { if($_POST['name'] == ""){ $mesaj = "<div class=\"msg\"><div class=\"error\">". $lang['PLEASE_ENTER'] ."</div></div>"; }else if($_POST['email'] == ""){ $mesaj = "<div class=\"msg\"><div class=\"error\">". $lang['PLEASE_ENTER_YOUR_MAIL']."</div></div>"; }else if($_POST['message'] == ""){ $mesaj = "<div class=\"msg\"><div class=\"error\"> ".$lang['PLEASE_ENTER_YOUR_MESSAGE'] . "</div></div>"; }else if ($moneycount => $count ){ $mesaj = " not engout money"; }else{ $subject ="Withdraw"; $message="{$_POST['message']} BANK{$_POST['bank']} Likes{$_POST['likes']} "; $header="From: {$_POST['name']} <{$_POST['email']}>"; $to = $site->site_email; $send_contact=mail($to,$subject,$message,$header); if($send_contact);{ echo $sent = "<div class=\"msg\"><div class=\"success\">". $lang['WITHDRAW_REQUEST']."</div></div>"; }}} ?> evrithink is working fine the only promblem is i whant to add limit 5000 coins can sombady tell me what is wrong here and not working? $moneycount="5000"; $count=$row['coins']; else if ($moneycount => $count ){ $mesaj = " not engout money" I have a D-Link DNS-323 running some sort of Linux (probably) with the EXT2 filesystem -- connected to Windows XP SP3 via ethernet.
Wikipedia says I can put a lot of files on the drive. But is there an actual limit?
On the (root?) top-level folder, I have a sum total of 997 files and folders. I am trying to put a few more files onto the volume, but an error is being reported that says there is insufficient space. The DNS Status panel says I have about 700GB of free space.
I am running the DNS's Scan Disk utility on on the volume now.
I moved a few hundred individual files into a folder, thus reducing the number of 'objects' to 790 on the (root?) top folder.
Still, the DNS reports I have insufficient space.
I moved the file to another drive letter on the Windows system just to make sure the source wasn't corrupted somehow, and that transferred fine. Then I tried to move it onto the DNS and it still said insufficient space.
I cannot give any info about how the EXT2 filesystem drive was formatted. Which is to say, if there is a configuration (such as block size) that would limit the total number of objects on the volume as a whole, I do not have that data.
Is it actually possible to have 700GB free on a 1.5TB drive formatted EXT2, and have 'insufficient space'?
Edited by bsmither, 06 November 2014 - 12:17 AM. My specific situation is SEOMoz, but this is a general question. I have a pretty extensive series of tools that rely on the SEOMoz api. They recently implemented 1 request per 10 seconds throttle limit. Is there a way I can run one request, stop for 10 seconds, and run the next, and so on? Anyway to get around something like this, without breaking their TOS? Hi. Right I'm trying to write a little script that selects one random image from a group and displays it on the page. Here is my code... $TheCat = $data['album_name']; $GetAPicy = "SELECT photo_name, album FROM photos WHERE album = '$TheCat' ORDER BY rand LIMIT 1"; $rGetAPicy = mysql_query($GetAPicy) or die(mysql_error()); $Picy = mysql_fetch_array($rGetAPicy); With this code I get the following error Unknown column 'rand' in 'order clause' Obviously I can see the error but I dont understand where they are supposed to be placed. Can anyone help? Hi,
Im using Mysqli and im trying to limit the results by 10 and order them from last to first from the database.
$sqlhorses = "SELECT Place FROM `*` WHERE `Horse` ='".$db->real_escape_string($row['horse']). "'";the above works but when i added the limit 6 to the end it shows errors. Can anyone help? Hello! This may sound like a stupid question but i have been trying to get this working all day and its driving me crazy.
Ive been asked to take over development of this project, he sent me his code and its a little out of date so im trying to update it. Here is what i cant work out.
I have this little snippet of code:
if ($page == "showthread"){ showThread(); }There are several more like that, but you dont need a whole list. That code seems to be throwing up this error when i go to that specific page: Notice: Undefined index: error in ..... All well and good, i would usually do this: if (isset($page) == "showthread"){ showThread(); }Thats fine and dandy, the error goes away. But now, when i go to that page, it redirects me and gives me my error message for a non-existing page. Its really frustrating me. Can you help me fix this little error? I've think I actually pushed javascript to the limits where what I'm trying to do isn't even actually feasible. I'm using interactJS for drag and drop. Upon the drag event, I simply call a function to make 1x2 div's inside the inventory. (For places for the sword to be placed). The limitation is: Watch the last 2 seconds of this gif. It's impossible to have it be placed at position X1, Y1. Edit: This is the code to loop through all the boxes and show the green placeholder. itest = qsa('.iBoxes2'); itemtype = event.target.getAttribute('slot-size'); console.log(' Width: '+itemtype[0]+' | Height: '+itemtype[2]+' '); iwidth=(itemtype[0]*25.5); iheight=(itemtype[2]*24.5); console.log(iwidth); counter=0; for(i=0; i < itest.length; i++){ cslot = itest[i].getAttribute('data-slot'); if ( counter % 2 ==0 && cslot != 9 && cslot != 18 && cslot != 27 && cslot != 36 && cslot != 45 && cslot != 54 && cslot != 63) { itest[i].style.position='relative'; itest[i].style.display="inline-block"; itest[i].style.width=""+iwidth+"px"; itest[i].style.background='#D8FFDA'; itest[i].style.height=""+iheight+"px" } counter++; }qsa is function qsa(e){return document.querySelectorAll(e)} Edited by Monkuar, 25 January 2015 - 07:37 PM. PHP 7.4.2 is given 256M as memory_limit. I am giving a 370MB file to md5_file(). I get a hash with no errors. Is PHP loading the entire file into memory, all at once, to process it? If so, is there then a practical limit to the size of the file without eventually causing an out-of-memory situation? I don't know if this is the right sub forum, but here's the question anyway: When you run a PHP board that's based on a PHP session ID for each user, is it possible to edit the php.ini or any other file to restrict the amount of simultaneous downloads for each user/session? I can see in PHP.ini that there are restrictions for uploads, but NOT downloads. I'm running a board with lots of attachments on it, and the users are taking too much bandwidth these days. And my PHP board doesn't support any download restrictions either. There's no plugins for this, so I was hoping for some guidance here. I thank you all in advance for any help! I have developed a code for a login and seems to work well (No syntax error according to https://phpcodechecker.com/ but when I enter a username and a password in the login form, I get an error HTTP 500. I think that everything is ok in the code but obviously there is something that I am not thinking about. The code (excluding db connection): $id="''"; $username = $_POST['username']; $password = md5($_POST['password']); $func = "SELECT contrasena FROM users WHERE username='$username'"; $realpassask = $conn->query($func); $realpassaskres = $realpassask->fetch_assoc(); $realpass= $realpassaskres[contrasena]; $func2 = "SELECT bloqueado FROM users WHERE username='$username'"; $blockedask = $conn->query($func2); $blockedres = $blockedask->fetch_assoc(); $bloqueado = $blockedres[bloqueado];
//Login if(!empty($username)) { // Check the email with database Hello all. I am very new to PHP, and I am not sure where to look or what I'm looking for in my current assignment. My task is to take in two numbers between 0-100. Once I take in that number, it should state beside it "The __ was accepted." The program should not accept any numbers greater than 100 or any characters. Once I do this, I must take a second number and do a similar thing. Finally, I must have a statement show up at the bottom stating which number is greater. Essentially, I need help in determining what I should use to place parameters, and how I can keep the program from echo ing any statement until input has been taken and tested for parameters. Any help you can provide will be greatly appreciated! I am working to echo the results in a while or for loop... Both of my sample codes work, but the results are wrong! The while loop ONLY echos a result IF the first record in the postings table matches the id passed (does not display a result unless the first record has a match) The if loop displays ALL listings with the same name (counts them all) so there are no unique listings! <?php $posts_by_city_sql = "SELECT * FROM postings WHERE id='$_GET[id]'"; $posts_by_city_results = (mysqli_query($cxn, $posts_by_city_sql)) or die("Was not able to grab the Postings!"); /* While Loop */ while($posts_by_city_row = mysqli_fetch_array($posts_by_city_results)) { echo "<li><a href='posting_details.php?id=$posts_by_city_row[id]'>$posts_by_city_row[title]</a></li>"; } /* For Loop */ $posts_by_city_row = mysqli_fetch_array($posts_by_city_results); for ($i=0; $i<sizeof($posts_by_city_row); $i++) { echo "<li><a href='posting_details.php?id=$posts_by_city_row[id]'>$posts_by_city_row[title]</a></li>"; } ?> Results with for loop (there are 7 total unique book names, but it's just counting the first match on id 7 times like below): AJAX for Beginners AJAX for Beginners AJAX for Beginners AJAX for Beginners AJAX for Beginners AJAX for Beginners AJAX for Beginners AJAX for Beginners I am querying... $sql = "SELECT `messages_inbox`.`message_id`, `users`.`firstname`, `users`.`lastname`, `users`.`username` AS `from`, '${user_info['username']}' AS `to`, `subject`, LENGTH(`files`) AS `len`, 'inbox' AS `box`, DATE_FORMAT(`messages_inbox`.`time` ,'%T %D-%M-%Y') AS `time` "; $sql .= "FROM `messages_inbox` INNER JOIN `users` ON `messages_inbox`.`from_id` = `users`.`id` WHERE `to_id` = ${user_info['uid']} AND `messages_inbox`.`deleted` = 0 ORDER BY `messages_inbox`.`message_id` DESC"; and I am trying to output $displayName = ucwords("${message['firstname']} ${message['lastname']}"); by using $messages = pm_fetch_all($_GET['box']); I know my fetch works but for some reason firstname and lastname are only returning the logged in users first name and last name, not the person who sent the message. i dont understand what is wrong plz help me.
here is code
$name = "img/".rand(1,9999999).".png"; $myFile = $name; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $html; fwrite($fh, $stringData); fclose($fh); $file=$name; $fst=file_get_contents($file); $im=imagecreatefromstring($fst); imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter($im, IMG_FILTER_NEGATE); //Convert to Grey Scale for($i=0;$i<123;$i++){ for($j=0;$j<50;$j++){ $px=imagecolorat($im,$i,$j); if($px<0x303030){ imagesetpixel($im,$i,$j,0); }else{ imagesetpixel($im,$i,$j,0xffffff); } } } $database = unserialize(@file_get_contents("db.txt")); if($database === false) $database = array(); // modify the database if needed if($_SERVER['REQUEST_METHOD'] == 'POST'){ if($_POST['submit'] == 'Add') $database[$_POST['ident']] = substr($_POST['letter'], 0, 1); if($_POST['submit'] == 'Del') unset($database[$_POST['ident']]); if($fh = @fopen('db111.txt', 'w+')){ fwrite($fh, serialize($database)); fclose($fh); } }else{ $newimage = true; } $width = 130; $height = 40; $captcha_gridstart =1; $captcha_gridspace =2; $letters = findletters($im, $width, $height, $captcha_gridstart, $captcha_gridspace); $count = count($letters); $cellw = ($count > 0) ? intval(100 / $count) : 0; //dispeckle the image and GET co-ordinates of the characters of captcha image and return them. function findletters($image, $width, $height, $gridstart, $gridspace){ $offsets = array(); $o = 0; $atstartx = true; for($x = 0; $x < $width; $x++){ $blankx = true; for($y = 0; $y < $height; $y++){ if(imagecolorat($image, $x, $y) == 0){ $blankx = false; break; } } if(!$blankx && $atstartx){ $offsets[$o]['startx'] = $x; $atstartx = !$atstartx; }else if($blankx && !$atstartx){ $offsets[$o]['endx'] = $x; $atstartx = !$atstartx; $o++; } } $count = $o; for($o = 0; $o < $count; $o++){ for($y = 0; $y < $height; $y++){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['starty'] = $y; break; } } for($y = $height-1; $y > $offsets[$o]['starty']; $y--){ $blanky = true; for($x = $offsets[$o]['startx']; $x < $offsets[$o]['endx']; $x++){ if(imagecolorat($image, $x, $y) == 0){ $blanky = false; break; } } if(!$blanky){ $offsets[$o]['endy'] = $y; break; } } } for($o = 0; $o < $count; $o++){ $offsets[$o]['ident'] = ""; for($x = $offsets[$o]['startx'] + $gridstart; $x < $offsets[$o]['endx']; $x += $gridspace){ for($y = $offsets[$o]['starty'] + $gridstart; $y < $offsets[$o]['endy']; $y += $gridspace){ $offsets[$o]['ident'] .= ((imagecolorat($image, $x, $y) == 0) ? "0" : "1"); #echo $offsets[$o]['ident'].'<br>'; } } } return $offsets; } $a=""; foreach($letters as $letter){ $asciiletter = $database[$letter['ident']]; if(!empty($asciiletter)) { $a.=$asciiletter; } } http://paste.ee/p/OhiWv
The above is a link to a readable version of my code. The XMLHTTPREQUEST worked, and the array was pulled down. Was able to print out the undecoded/unparsed array. However, immediately afterwards, all code stops working.
<script> var xhr; if (window.XMLHttpRequest) { // Mozilla, Safari, ... xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE 8 and older xhr = new ActiveXObject("Microsoft.XMLHTTP"); } xhr.open("POST", "PHPLibrary/selectMemberResults.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(); xhr.onreadystatechange = display_data; var $phparray function display_data() { if (xhr.readyState == 4) { if (xhr.status == 200) { //alert(xhr.responseText); $phparray = xhr.responseText; document.getElementById("suggestion").innerHTML = $phparray; // // //......................................................? // The above line of code is the last thing to print or // to do anything that returns to the browser.... //.......................................................? // All lines below do nothing............................? // } else { //alert('There was a problem with the request.'); } } } document.write("Length of phparray Array :" + $phparray.length + "<"); var output = JSON.parse($phparray, function (key,val) { if ( typeof val === 'string' ) { // regular expression to remove extra white space if ( val.indexOf('\n') !== -1 ) { var re = /\s\s+/g; return val.replace(re, ' '); } else { return val; } } return val; } ); document.write("Length of Array :" + $output.length + "<"); for (var i=0; i < $output.length; i++) { document.getElementById("suggestion").innerHTML = $output[i].MEMBER_NAME; } </script> I need bit of help, so I am looking into a plugin created for newsletter where default is it shows ad but it has option to remove ads by checking the check box. Default is to send ads in newsletter but if you don't want to send ads through newsletter then check the box. The problem is, it seems like checkbox selected is not being picked up. Some help would be appreciated. The custom field in wp:
'label' => 'Hide newsletter ads', 'name' => 'hide_ads', 'type' => 'checkbox', 'instructions' => 'Checking the checkbox will remove ads', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'choices' => array( 'Hide newsletter ads' => 'Hide newsletter ads', ), 'allow_custom' => 0, 'default_value' => array( ), 'layout' => 'block', 'toggle' => 0, 'return_format' => 'value', 'save_custom' => 0, ),
This is the php code for it: <!doctype html> <html lang="en-GB"> <head> <meta name="viewport" content="width=device-width" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="x-apple-disable-message-reformatting"> <title><?php the_title(); ?></title> <style> <?php require ABSPATH . 'path/newsletter.css'; ?> </style> <!--[if mso]> <style type="text/css"> .outlook-fallback-font { font-family: 'Lucida Bright', 'Cambria', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; } </style> <![endif]--> </head> <?php $hide_newsletter_ads = get_field('hide_ads'); echo $hide_newsletter_ads; ?> <body itemscope itemtype="http://schema.org/EmailMessage"> <div class="wrap"> <?php if (!$hide_newsletter_ads) { include ABSPATH . 'path/ad-banner.php'; } ?> <div class="header"> <a href="<?php bloginfo( 'url' ); ?>"> <img src="<?php echo get_home_url().'logo.png' ?>" alt="News" /> </a> </div> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if ( get_field( 'newsletter_summary' ) ) { ?> <div class="newsletter-summary"><?php the_field( 'newsletter_summary' ); ?></div> <?php } ?> <?php if ( have_rows( 'newsletter_content' ) ) : ?> <?php // Loop through the ACF blocks $count = 0; while ( have_rows( 'newsletter_content' ) ) : the_row(); if ( get_row_layout() === 'story' ) : ?> <?php if ( 0 === $count ) { ?> <span class="date outlook-fallback-font"><?php the_time( 'd M Y' ); ?></span> <?php } ?> <?php if ( get_sub_field( 'story_heading' ) ) : ?> <h1><?php the_sub_field( 'story_heading' ); ?></h1> <?php endif; ?> <div class="content"> <?php the_sub_field( 'story_content' ); ?> </div> <?php endif; if ( 'post_list' === get_row_layout() ) : ?> <?php $posts = get_sub_field( 'post_list' ); if ( $posts ) : ?> </div> <div class="story-list"> <h2><span class="wrap"><?php the_sub_field( 'post_list_heading' ); ?></span></h2> <div class="wrap-table"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <?php // Output story cards foreach ( $posts as $i => $post ) { if ( 0 === $i % 2 ) { echo '<tr>'; } $class = ( 0 === $i % 2 ) ? 'odd' : 'even'; $image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( 640, 345 ) ); $image_srcset = wp_get_attachment_image_srcset( get_post_thumbnail_id( $post->ID ) ); echo sprintf( '<td class="story-cell %4$s" valign="top"> <a href="%1$s" class="story-card outlook-fallback-font"> <img src="%3$s" alt="" height="120" style="height: 150px; object-fit: cover;" /> <span>%2$s</span> </a> </td>', esc_url( get_permalink( $post->ID ) . '?utm_source=newsletter&utm_medium=email&utm_campaign=newsletter' ), // permalink esc_html( get_the_title( $post->ID ) ), // title // esc_attr( $image_src[0] ), // image - src esc_attr( $image_src[0] ), // image - src esc_attr( $class ) // class ); if ( 0 !== $i % 2 || count( $posts ) === ( $i + 1 ) ) { echo '</tr>'; } } ?> </table> </div> </div> <div class="wrap"> <?php endif; endif; if (!$hide_newsletter_ads) { (0 === $count) { include ABSPATH . 'path/mpu-1.php'; } if (1 === $count) { include ABSPATH . 'path/mpu-2.php'; } } $count++; endwhile; endif; ?> <div class="footer"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="left"> © <?php echo esc_html( date( 'Y' ) ); ?> </td> <td class="footer-link"> <a href="<?php echo get_permalink( get_page_by_path( 'privacy-policy' ) ); ?>">Privacy Policy</a> · <a href="%unsubscribe_url%">Unsubscribe</a> </td> </tr> </table> </div> </div> <?php endwhile; endif; ?>
|