PHP - Order By And Limits
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? Similar TutorialsI'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; } 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. 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" 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? 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? 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! 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>
Hi everyone. I'm very new into self learning programming. Presently I'm trying to develop a simple basic Robot that would only Place a Market Order every seconds and it will cancel the Order every followed seconds. Using the following library: It would place Trade Order at a ( Price = ex.com api * Binance api Aggregate Trades Price) I have already wrote the api to call for xe.com exchange rate with php <?php $auth = base64_encode("username:password"); $context = stream_context_create([ "http" => [ "header" => "Authorization: Basic $auth" ] ]); $homepage = file_get_contents("https://xecdapi.xe.com/v1/convert_from?to=NGN&amount=1.195", false, $context ); $json = json_decode($homepage, TRUE); foreach ($json as $k=>$to){ echo $k; // etc }; ?> And also for the Binance Aggregate Price in JavaScript
<script> var burl = "https://api3.binance.com"; var query = '/api/v3/aggTrades'; query += '?symbol=BTCUSDT'; var url = burl + query; var ourRequest = new XMLHttpRequest(); ourRequest.open('GET',url,true); ourRequest.onload = function(){ console.log(ourRequest.responseText); } ourRequest.send(); </script>
My problem is how to handle these two api responds and also the functions to use them to place a trade and cancel it. 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've got. I need to make 0, which displays as POA appear at the ned of the list not at the begining, I currently just use order by price asc and 0 is at the beginning, i need to make 0 at the end Hi there, just registered and in need of help, this looks a good place to start! I'm a php beginner so please bear with me I have a mysql database which holds 3 pieces of info id: match: 1: I'm trying to sort the results using ORDER BY match ASC but for some reason it's just not for having it... Can't work out if it's an error with my php code or my table. I can order by "ID" no problem but I when I try ordering alphabetically by "match" it won't. my code is: Code: [Select] mysql_connect("***.***.***") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $query = "SELECT * FROM employees WHERE flag = 'tv' ORDER BY match ASC"; $result = mysql_query($query) or die ("Query failed"); $numrows = (mysql_num_rows ($result)); // loop to create rows if($numrows >0){ echo "<table width = 100% border = '0' cellspacing = '2' cellpadding = '0' >"; // loop to create columns $position = 1; while ($row = mysql_fetch_array($result)){ if($position == 1){echo "<tr>";} echo " <td align = 'center'><a href=\"http://www.website.eu/sport-stream/1/{$row['id']}.html\" target=_blank>{$row['match']} <br> <img src=\"{$row['8']}\" width=\"100\" height=\"70\" /> </a> </td> "; if($position == 4){echo "</tr> "; $position = 1;}else{ $position++;} }//while $end = ""; if($position != 1){ for($z=(4-$position); $z>0 ; $z--){ $end .= "<td></td>"; } $end .= "</tr>"; } echo $end."</table> "; }//if And here's a cap of my database: any help for a php n00b would be greatly appreciated! I got this code from a previous thread: Code: [Select] mysql_query("SET @rows = 0;"); $res = mysql_query("SELECT @rows:=@rows+1 AS view_rank,COUNT(id) AS views, credit_members_id FROM vtp_tracking GROUP BY credit_members_id ORDER BY views DESC"); $n = array(1 => 'st', 2 => 'nd', 3 => 'rd'); while($row = mysql_fetch_row($res)) { if ( $row[2] != $members_id ) continue; if ( substr($row[0], -1) < 4 ) { $row[0] .= $n[$row[0]]; } else { $row[0] .= 'th'; } echo ' You are in ' . $row[0] . ' place with ' . number_format($row[1]) . ' views.'; break; } Everything seems ok except it orders by the "credit_members_id" and not "views" as entered. Can someone explain why, and how to fix this? Hello, I have classes in a database with no set UNIX date, just the day like Wednesday and in two other columns the start and end dates. I want to be able to order by the day first and then by end_time but php orders the day column by spelling and not the day it holds in chronological order. Is there anyway to change the query to order the day column as a date? See the query below? Code: [Select] $query = "SELECT * FROM zumba_timetable WHERE end_time>'$current_time' ORDER BY day, end_time ASC LIMIT 0,1"; Currently i have a query which at the end has this Code: [Select] order by (value/counter) desc"); which works fine, however i was wondering, if in the case that 2 rows have the same, is it possible to set a second value to order by? I'm working on a simple ad server and would like to display the ads in order (not random). I'm fairly certain I can do something like this: Code: [Select] // Get the last ad id, or becomes 0 if not available $lastid = ($_GET['lastid'] == '') ? '0' : $_GET['lastid']; // Get the next ad in order, or get the first one available mysql_query("SELECT adcode FROM ads WHERE zone='$zoneid' AND id > $lastid ORDER BY id ASC LIMIT 1"); The above code would get the first ad or the next ad in order.. How do I go back to the beginning when I run out of ads to show? Evening everyone I wonder if you can help me with the below code <table width="823" cellspacing="0" id="mytable" summary="User Transactions Summary"> <caption>Transaction Summary</caption> <tr> <th width="136" class="nobg" scope="col" abbr="Merchant Name">Merchant Name</th> <th width="154" scope="col" abbr="Order Value">Order Value</th> <th width="145" scope="col" abbr="Comm">Cash Back</th> <th width="278" scope="col" abbr="Status">Status</th> </tr> <?php $result = mysql_query("SELECT * FROM transactions WHERE u_id = '$u_id' ORDER BY order_date DESC LIMIT 10 "); echo mysql_error() ; while($row = mysql_fetch_assoc($result)){ $m_name = $row['m_name']; $orderval = $row['order_val']; $status = $row['order_status']; $m_affid = $row['m_affid']; $query = mysql_query(" SELECT percent FROM merchants WHERE m_affid = '$m_affid' LIMIT 1"); $num = mysql_num_rows($query); $i=0; while ($i < $num) { $per=mysql_result($query,$i,"percent"); $i++; } $com1 = $orderval / 100; $com2 = $com1 * $per; $u_comm = round($com2,2); ?> <tr> <th scope="row" abbr="<?php echo $m_name;?>" class="spec"><?php echo $m_name;?></th> <td class="alt">£<?php echo $orderval ;?></td> <td class="alt">£<?php echo $u_comm ;?></td> <td class="alt"><?php echo $status ;?></td> </tr> <?php }?> </table> Basically it is meant to simply show fields from a database in a table. If there is only 1 entry for a u_id it works fine, however if their is more than one then the $u_comm value shows the same for all results, which is for the last result/row found. Hope this makes sense! |