PHP - Need Reference To Auto Insert Integers
I am wondering how can I insert integers in the database without manually input it in the form.
I am looking to fill the product_id and customer_id table. I would do it but only by sequence and '' quotes at the VALUE part of an INSERT statement. Also condition the insert of product_id and customer_id according to the id in the SESSION variable. Code: [Select] <?php session_start(); if (isset($_SESSION['id'])) { $userid = $_SESSION['id']; $username = $_SESSION['username']; $fname = $_POST['firstname']; $lname = $_POST['lastname']; $telephone = $_POST['telephone']; $city = $_POST['city']; $state = $_POST['state']; $itemname = $_POST['product_name']; $price = $_POST['price']; $details = $_POST['details']; $category = $_POST['category']; $subcategory = $_POST['subcategory']; $product_id = $_POST['product_id']; $customer_id = $_POST['customer_id']; $date_sold = $_POST['date_sold']; $sqlinsert = "INSERT INTO customers (id,firstname,lastname,telephone,city,state,product_name,price,details) VALUES('','$fname','$lname', '$telephone','$city','$state','$itemname','$price','$details')"; $sqlinsert2 = "INSERT INTO products (id,product_name,price,details,category,subcategory) VALUES('','$itemname','$price','$details','$category','$subcategory')"; $sqlinsert3 = "INSERT INTO sales (id,product_id, customer_id, date_sold) VALUES('','$product_id','$customer_id','$date_sold')"; $enterquery = mysql_query($sqlinsert) or die(mysql_error()); $enterquery2 = mysql_query($sqlinsert2) or die(mysql_error()); $enterquery3 = mysql_query($sqlinsert3) or die(mysql_error()); } ?> The above insert its respective fields in each table but how is it possible to INSERT it according to the SESSION['id]; so that it INSERT according to the costumer id plus that it generates and INSERT automatically in the product_id and customer_id related to the product_id and customer_id fields in products and customer table? without manually doing it. any references will be appriciated because the above code seems like the product_id and customer_id won't INSERT in relations to the customer and product table. One more thing the product_id and customer_id won't be pass from the form to this file but rather a value will be INSERT it in their field according to the id in customer and products table. Similar TutorialsHello, I'm having a bit of a problem here, all help to this issues would be much appreciated I am trying to use text boxes to insert numbers into the database based on what is inputed. If I have a string, like this for example: $variable = 09385493; And I want to insert it into the database like this: mysql_query("INSERT INTO integers(number) VALUES ('$variable')"); When checking the integers table in my database, looking at the number field, the $variable that was inserted is outputted as 9385493 Notice the number zero was taken out of the front of the number. If the number is double 0's (009385493), both of those zero's would disappear, too. Thanks how do I pull out two random integers at the same time without ever possibly choosing the same integer twice? Code: [Select] if( date('j') < 1 && > 14) { $EnrollDate = "1/".date('n')."/".date('y'); }else { $EnrollDate = "15/".date('n')."/".date('y'); } What could be wrong here, i cant work! i hit a wtf moments print $_POST['idName']; // prints 0, correct, the value of the selected select element item is indeed 0 print '<br>'; $value = intval($_POST['idName']); // otherwise its a string if($value == 'empty') { print '<br>wtf does this get printed?'; } the $values value is the number zero, not the string 'empty', so why does it eval as one? I almost have this right, but not quite. I am trying to echo out the average score if a person scored above 70 and my averaging isn't correct. It should echo out 89, but instead the number is 63.25. The averaging is the only part not working. Everything else works as intended. I might not have my curly braces in the proper order or something. I think it's something stupid I am forgetting. Here is my code. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Array Test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php function array_average_nonzero($scores) { return array_sum($scores) / count(array_filter($scores)); } $scores["Tim"] = 98; $scores["Tom"] = 80; $scores["Mike"] = 50; $scores["Jason"] = 25; foreach( $scores as $key => $value) if($value < 70){ echo "$key scored a $value which is less than 70. <br />\n"; } elseif ($value < 70); { echo "The average score of those who scored over 70 is: " .array_sum($scores) / count($scores) . "<br />"; } ?> </body> </html> Hi,
Is there any way to use the inbuilt filter functions in PHP to filter for integer values greater than 256? All examples that I saw had a max_range of 256. Kindly suggest. Thanks.
Hi everybody, a few dasy ago i found a function which translates integers into text like this:
echo $number->written_number(101); // one hundred one
but i've got a problem, this function works fine on russian language, but that this function translate in 3 languages:
russian, english and ukrainian like this:
echo $number->written_number(101); // сто один - one hundred one - сто один
how can i add english and ukrainian languages?
When i tried to add this manually, it was okay but in one moment i received error, and all my script is broked, and now i don't know what to do, i've got a few hours to complete this test work, but unfortunately i've got no idea how to do this(
Pls help me somebody, i will infinitely grateful!!!
This is my code
<?php require_once('languages.php'); class numberTransfer extends languages { public function written_number($i, $female = false) { if (($i < 0) || ($i >= 1e9) || !is_int($i)) { return false; // Аргумент должен быть неотрицательным целым числом, не превышающим 1 миллион } if($i == 0) { return $this->N0. '</br>' .$this->N0eng; } else { return preg_replace( array('/s+/','/\s$/'), array(' ',''), $this->num1e9($i, $female) ); return $this->num1e9($i, $female); } } public function num_125($n) { /* форма склонения слова, существительное с числительным склоняется одним из трех способов: 1 миллион, 2 миллиона, 5 миллионов */ $n100 = $n % 100; $n10 = $n % 10; if(($n100 > 10) && ($n100 < 20)) { return 5; } elseif($n10 == 1) { return 1; } elseif(($n10 >= 2) && ($n10 <= 4)) { return 2; } else { return 5; } } public function num1e9($i, $female) { if($i < 1e6) { return $this->num1e6($i, $female); } else { return $this->num1000(intval($i/1e6), false) . ' ' . $this->Ne6[$this->num_125(intval($i/1e6))] . ' ' . $this->num1e6($i % 1e6, $female); } } public function num1e6($i, $female) { if($i < 1000) { return $this->num1000($i, $female); } else { return $this->num1000(intval($i / 1000), true) . ' ' . $this->Ne3[$this->num_125(intval($i/1000))] . ' ' . $this->num1000($i % 1000, $female); } } public function num1000($i, $female) { if($i < 100) { return $this->num100($i, $female); } else { return $this->Ne2[intval($i/100)] . (($i % 100)?(' '. $this->num100($i % 100, $female)):''). '</br>' .$this->Ne2eng[intval($i/100)]. (($i % 100)?(''. $this->num100($i % 100, $female)):'') ; } } public function num100($i, $female) { $gender = $female?1:0; if ($i < 20) { return $this->Ne0[$gender][$i]. '</br>' .$this->Ne0eng[$gender][$i]; } else { return $this->Ne1[intval($i / 10)] . (($i % 10)?(' ' . $this->Ne0[$gender][$i % 10]):''). '</br>' . $this->Ne1eng[intval($i / 10)] . (($i % 10)?(' ' . $this->Ne0eng[$gender][$i % 10]):''); } } } $number = new numberTransfer(); echo $number->written_number(101);as you can see i tried to glue array with russian language words with array with english laguage words. Probably i've got somethink like this: $number = new numberTransfer(); echo $number->written_number(101); сто один one one hundredодин one damn bullshit... Please people help me:) Is it possible to perform type declaration which allows either an integer or a string digit (i.e. ctype-digit) instead of the following? function someFunction(int $id){} Looking at functions.arguments.type-declaration, I expect not. If not, would you recommend type casting before calling the function or removing type declaration from the function and performing the check manually within the function and throwing an applicable exception? Thanks Well the topic may not sound very explicit. So I'll do my best to explain it here. I have a pull down menu as part of a form, which contains the months of the year. I'm trying to store the value of this form entry using the $_POST['month'] variable into a database but first, I need to convert the month values into their corresponding integer values( that is 1 for January, 2 for February etc), in order to easily do date calculations later down the road. Any ideas about how to do this? It may be helpful to include the code for the pull down menu. Code: [Select] <p><tab> Date of Birth: <?php //Make the month pull down menu. //Array to store months. $months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); print '<select name= "month">'; foreach ($months as $key => $value) { print "\n<option value=\"$key\">$value</option>"; } print '</select>'; ?> </tab> <tab> <?php //Make the day pull down menu print '<select name= "day">'; for ($day = 1; $day <= 31; $day++) { print "\n<option value=\"$day\">$day</option>"; } print '</select>'; ?> </tab> <tab><?php //Make the year pull down menu print '<select name= "year">'; $start_year = date('Y'); for ($y = ($start_year - 18); $y >= 1900; $y--) { print "\n<option value=\"$y\">$y</option>"; } print '</select>'; ?> </tab> </p> Hi, I'm trying to retrieve the integer value between the <span> tag from a HTML source code.
HTML source code:
<span> (3861822) </span>This is the php code: <!DOCTYPE html> <html> <body> <?php //use curl to get html content function getHTML($url,$timeout) { $ch = curl_init($url); // initialize curl with given url curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); // set useragent curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // max. seconds to execute curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error return @curl_exec($ch); } $html=getHTML("http://www.alibaba.com/Products",10); preg_match("/<span>(.*)<\/span>/i", $html, $match); $title = $match[1]; echo $title; ?> </body> </html>Whenever I try to run it, this error will come out: Notice: Undefined offset: 1 in C:\xampp\htdocs\myPHP\index.php on line 19. How to correct it so that it will display all the integer value within the tag name but without the bracket? Thanks Edited by Raex, 20 August 2014 - 01:38 AM. So a project I have simply to learn how it is done is to make an auto updating sitemap with a auto submitter. I have been doing a little research on sitemaps but haven't found much in the way of a tutorial or white paper or similar, anyway I was wondering if I am on the right track or not. What I was thinking for the auto-updating sitemap is since site maps are XML, when an article is published using my custom CMS/Blogging system, I make it rewrite the sitemap appending the new URL that will be generated. Then for the auto-submit, I can either make it a cron job or just manual press, but it would go though a for list of URLs, replacing the end part with my site map url. I think that is how it would be done. If you have a better idea, or can point out an article so I can understand a lot more with sitemaps, I will appreciate it, I am trying to learn as much as possible, I have gone to the offical website (sitemaps.org) but it doesn't have what I am looking for. Thanks, James //php code <?php include_once('con.php'); if(!empty($_GET['search'])) { $search = $connect->prepare('SELECT * FROM posts WHERE title LIKE :search'); $search->bindValue(':search', '%'.$_GET['search'].'%', PDO::PARAM_STR); $search->execute(); ?> <?php while($row = $search->fetch()) {?> <li class="result" onClick="searchValue('<?php echo $row['title'];?>')"><?php echo $row['title'];?></li> <?php } ?> <?php } ?> //ajax $('#inputsch').keyup(function(){ $.ajax({ type: 'GET', url: 'fetch.php', data:'search='+$(this).val(), success: function(data){ $('#box').show(); $('#box').html(data); } }); }); }); function searchValue(val) { $('#inputsch').val(val); $('#box').hide(); } //search box <form action="search.php"> <input id="inputsch" type="text" name="search" placeholder="search..." autocomplete="off" autofocus> <button type="submit" value="search" >search</button> </form> <div id="box"></div> //the problem here is when i click the result is only added to input, but i want it to autosubmit
I'm missing something here. I have a form, and when the submit is pressed, the relevant post data inserts into table one, then I want the last insert id to insert along with other form data into a second table. The first table's still inserting fine, but I can't get that second one to do anything. It leapfrogs over the query and doesn't give an error. EDIT: I forgot to add an error: I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'usage, why VALUES ('14', '', '123', '','1234', '', '')' at line 1 query:INSERT INTO tbl_donar (donar_fname, donar_name, donar_address, donar_address2, donar_city, donar_state, donar_zip, donar_email, donar_phone, donar_fax, donar_company) VALUES ('test 14', 'asdfa', 'asdf', 'adf','asdf', '', '', '', '123', '', '') Code: [Select] if (empty($errors)) { require_once ('dbconnectionfile.php'); $query = "INSERT INTO tbl_donar (donar_fname, donar_name, donar_address, donar_address2, donar_city, donar_state, donar_zip, donar_email, donar_phone, donar_fax, donar_company) VALUES ('$description12', '$sn', '$description4', '$cne','$description5', '$description6', '$description7', '$description8', '$description9', '$description10', '$description11')"; $result = @mysql_query ($query); if ($result) { $who_donated=mysql_insert_id(); $query2 = "INSERT INTO tbl_donation (donor_id, donor_expyear, donor_cvv, donor_cardtype, donor_authorization, amount, usage, why) VALUES ('$who_donated', '$donate2', '$donate3', '$donate4','$donate5', '$donate6', '$donate7')"; $result2 = @mysql_query ($query2); if ($result2) {echo "Info was added to both tables! yay!";} echo "table one filled. Table two was not."; echo $who_donated; //header ("Location: http://www.twigzy.com/add_plant.php?var1=$plant_id"); exit(); } else { echo 'system error. No donation added'; Can anyone tell me why this is not INSERTing? My array data is coming out just fine.. I've tried everything I can think of and cannot get anything to insert.. Ahhhh! <?php $query = "SELECT RegionID, City FROM geo_cities WHERE RegionID='135'"; $results = mysqli_query($cxn, $query); $row_cnt = mysqli_num_rows($results); echo $row_cnt . " Total Records in Query.<br /><br />"; if (mysqli_num_rows($results)) { while ($row = mysqli_fetch_array($results)) { $insert_city_query = "INSERT INTO all_illinois SET state_id=$row[RegionID], city_name=$row[City] WHERE id = null" or mysqli_error(); $insert = mysqli_query($cxn, $insert_city_query); if (!$insert) { echo "INSERT is NOT working!"; exit(); } echo $row['City'] . "<br />"; echo "<pre>"; echo print_r($row); echo "</pre>"; } //while ($rows = mysqli_fetch_array($results)) } //if (mysqli_num_rows($results)) else { echo "No results to get!"; } ?> Here is my all_illinois INSERT table structu CREATE TABLE IF NOT EXISTS `all_illinois` ( `state_id` varchar(255) NOT NULL, `city_name` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Here is my source table geo_cities structu CREATE TABLE IF NOT EXISTS `1` ( `CityId` varchar(255) NOT NULL, `CountryID` varchar(255) NOT NULL, `RegionID` varchar(255) NOT NULL, `City` varchar(255) NOT NULL, `Latitude` varchar(255) NOT NULL, `Longitude` varchar(255) NOT NULL, `TimeZone` varchar(255) NOT NULL, `DmaId` varchar(255) NOT NULL, `Code` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; hello. say i have list and i want the correct children under each parent so i have $id $parent_id $type $name in the db i have 4 parents each with 2 children id=1 - type=parent - parent_id=0 - name=p1 id=2 - type=parent - parent_id=0 - name=p2 id=3 - type=parent - parent_id=0 - name=p3 id=4 - type=parent - parent_id=0 - name=p4 id=5 - type=child - parent_id=1 - name=c1 id=6 - type=child - parent_id=1 - name=c2 id=7 - type=child - parent_id=2 - name=c3 id=8 - type=child - parent_id=2 - name=c4 id=9 - type=child - parent_id=3 - name=c5 id=10 - type=child - parent_id=3 - name=c6 id=11 - type=child - parent_id=4 - name=c7 id=12 - type=child - parent_id=4 - name=c8 so how would i do the code? i thought i could do it like this but its not working. Code: [Select] <?php $family = Family::find_all(); foreach($family as $familys){ $id = $familys->id; $type = $familys->type; $parent_id = $familys->parent_id; $name = $familys->name; echo' <ul>'; if($type == "parent"){ echo $name; } echo' </ul> <li>'; if($type == "child" && $parent_id == $id){ echo $name; } echo' </li>'; } ?> all i get back is p1 p2 p3 p4 no children ?? if i remove Quote $parent_id == $id from Quote if($type == "child" && $parent_id == $id){ i get this p1 p2 p3 p4 c1 c2 c3 c4 c5 c6 c7 c8 but they are not listed under the correct parent i also tried moving the </ul> to the bottom but i get the same Code: [Select] <?php $family = Family::find_all(); foreach($family as $familys){ $id = $familys->id; $type = $familys->type; $parent_id = $familys->parent_id; $name = $familys->name; echo' <ul>'; if($type == "parent"){ echo $name; } echo' <li>'; if($type == "child"){ echo $name; } echo' </li> </ul>'; } ?> any thoughts? thanks rick Hi all, I have been coding in PHP for a fair while now and I have come across variables by reference, but I don't really know: a) how they work; b) when to use them; c) why they are used; Can anyone here please clarify these issues please. Thanks in advance! Can someone explain this strange behavior: $aArray = array( 1 => null, 2 => null, 3 => null, ); foreach($aArray as $key => &$val) { $val = "Some Value"; foreach($aArray as $Xkey => $Xval){} // Second foreach } var_dump($aArray); Rsult is: array(3) { [1]=> string(10) "Some Value" [2]=> NULL [3]=> NULL } It looks like second foreach breaks reference, why? Hi, I just need someone to check that a couple of lines I've written do what I believe them to do... i.e. check my logic! I'm developing a booking form for booking on events. Each booking needs a unique reference, which needs to be meaningless to the customer, so I am BASE36 encloding it. As the booking is be saved to a MySql database, my approach is to use the auto-incremented ID for the record to make the reference unique. The increment starts at 10000, and I add a random number before coding to make the encoded reference longer. I then BASE36 encode it to make it appear random. Am I right in thinking the reference produced WILL be unique ... provided the auto-inc ID is unique? $ref = rand(100,999) . $auto_incremented_id; //e.g. 354 & 10012 = 35410001 $ref_encoded = strtoupper(base_convert($rand, 10, 36)); // e.g.UD4J8P Thanks Hello, I've just started learning PHP, JavaScript and I've got a big problem on my website. I'm getting this ReferenceError. I know what's the problem, but I don't know how to solve it, and I know people can do it for money but I don't have money, I'm searching for someone who's willing to help newbie. As I said I'm begginer, and I know something. The main problem is because I want to use GKPlugin and Player(jwplayer). Plugin need to use object, example:
<object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400"> <param name="movie" value="player.swf" /> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="FlashVars" value="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" /> <embed name="flashplayer" src="player.swf" FlashVars="plugins=plugins/proxy.swf&proxy.link=http://www.vidbull.com/53qx9uo10k5d" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" /> </object>Script is generetad just to embed with iframe, and the problem is when I replace it with object, then I'm getting this error. I know that JS can't "call" that iframe to show because I've replaced it with object. You guys probably know about what I'm talking. I'm just searching for some instructions, guidelines from you. ReferenceError: embeds is not defined if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){Here's the rest of code, I think it's used to show iframe. elseif (substr_count($link,"gorillavid")){ $video_id = explode("/",$link); if (isset($video_id[count($video_id)-1])){ $video_id = $video_id[count($video_id)-1]; $embed = '<object id="flashplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="400"> <param name="movie" value="http://www.kiinc.com/videott/player.swf" /> <param name="allowFullScreen" value="true" /> <param name="allowScriptAccess" value="always" /> <param name="FlashVars" value="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" /> <embed name="flashplayer" src="player.swf" FlashVars="plugins=http://www.kiinc.com/videott/plugins/proxy.swf&proxy.link=http://gorillavid.in/'.$video_id.'" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="600" height="400" /> </object>'; This is the original code. Don't look at providers(source as gorillavid) because I used gorillavid in previous an posted another example from another source (zalaa) elseif (substr_count($link,"zalaa")){ $video_id = explode("/",$link); if (isset($video_id[count($video_id)-1])){ $video_id = $video_id[count($video_id)-1]; $embed = '<IFRAME SRC="http://www.zalaa.com/embed-'.$video_id.'.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH='.$width.' HEIGHT='.$height.'></IFRAME>'; Function which embed links and should embed GKPlugin/Player: // general image link if (!$embed){ $embed = "<div style='background-color:#000000; width: ".$width."px; height: ".$height."px;text-align:center;cursor:pointer;' onclick='window.open(\"$link\");'>"; $embed.= "<p style='text-align:center; padding-top: 70px;'>"; $embed.= "<a href='$link' target='_blank' style='font-size:24px; color: #ffffff !important'>Click here to play this video</a>"; $embed.= "</p>"; $embed.= "</div>"; } return $embed; } JavaScript code: function getEmbed(embedid){ if (embeds[embedid].indexOf("rapidplayer")== iframe_ad){ var html_content = "<div class='fake_embed' id='fake_embed"+embedid+"' onclick='closeFakeEmbed("+embedid+");'>" + "<br /><br />" + "<div class='fake_embed_ad_close'><a href='javascript:void(0);' onclick='closeFakeEmbed("+embedid+");'>Close Ad</a></div>" + "<div class='fake_embed_ad' id='fake_embed_ad" + embedid +"'>" + "<iframe src='"+baseurl+"/iframe_ad.php' width='300' height='300' frameborder='NO' border='0'></iframe>" + "</div>" + "<div class='fake_embed_bar'><span class='fake_embed_bar_right'></span></div>" + "</div>" + "<div id='real_embed"+embedid+"' style='display:none'>"+embeds[embedid]+"</div>"; jQuery('#videoBox'+embedid).html(html_content); jQuery('#videoBox'+embedid).show(); } else { jQuery('#videoBox'+embedid).html(embeds[embedid]); jQuery('#videoBox'+embedid).show(); } } function countDown(embedid){ showCounter = showCounter-1; jQuery('span#counter').html(showCounter); if (showCounter>0){ showTimer = setTimeout('countDown('+embedid+');',1000); } else { showTimer = null; showCounter = 20; getEmbed(embedid); } } function changeEmbed(embedid, counter){ if (counter == 0){ jQuery('.embedcontainer').html(''); jQuery('.embedcontainer').hide(); getEmbed(embedid); } else { if (showTimer){ clearTimeout(showTimer); } showTimer = null; showCounter = counter; jQuery('.embedcontainer').html(''); jQuery('.embedcontainer').hide(); jQuery('#videoBox'+embedid).html(js_lang.ticker); jQuery('#videoBox'+embedid+' span#counter').html(showCounter); jQuery('#videoBox'+embedid).slideDown("slow"); showTimer = setTimeout('countDown('+embedid+');',1000); } /* jQuery('li.selected').removeClass('selected'); jQuery('#selector'+embedid).addClass('selected'); */ } I am writting a php function that uses mysql to get user data - pretty common, right Well, my issue is that I need to run a check in my file system. Users profile pictures are stored in my image directory as .png's. I need to have my function check that directory and if an image matches their id, then return their information. I only want the user data if they have an image uploaded. Here is my current function: Code: [Select] function fetch_users_login($limit) { $limit = $limit(int); $sql = "SELECT `users`.`id`, `users`.`firstname`, `users`.`lastname`, `users`.`username`, `user_privacy`.`avatar` FROM `users` LEFT JOIN `user_privacy` ON `users`.`id` = `user_privacy`.`uid` WHERE `users`.`status` > 2 AND `user_privacy`.`avatar` = 1 ORDER BY `users`.`id` DESC LIMIT 0, {$limit}"; $result = mysql_query($sql) or die(mysql_error()); $users = array(); $i = 0; while(($row = mysql_fetch_assoc($result)) !== false) { $users[$i] = array( 'id' => $row['id'], 'firstname' => $row['firstname'], 'lastname' => $row['lastname'], ); $users[$i]['avatar'] = getUserAvatar($row['username']); $i++; } return $users; } |