Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. Yeah, that's fine. I thought you were suggesting that you should put them into an array.
  2. Even though it's a subdomain it has a file system path, and that's what you need to pass to imagepng.
  3. The alternative to this loop would be a MySQL JOIN. Something like this: SELECT PHOTOS.*, AUTHOR.* FROM PHOTOS JOIN ON (PHOTOS.PHOTO_ID = AUTHOR.AUTHOR)
  4. I'm not entirely sure what you're asking, but I think what I posted in my first reply is what you're looking for.
  5. If not insert it into that row, or insert a new row?
  6. There's really no point in doing that.
  7. Depends on the game; it could be any of the above.
  8. $result = mysql_query("SELECT 1 FROM table WHERE col='something'"); if(mysql_num_rows($result)) { // update } else { // insert }
  9. This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=306073.0
  10. The whole thing is designed poorly to be honest. It would be a better idea to construct variables like $start and $limit outside of the function and make the pagination() function accept only what it needs in order to do its purpose. All of this stuff: $sql = "SELECT COUNT(*) as num FROM $tableName"; $total_pages = $connection->query($sql) or die(mysqli_error($connection)); $row = $total_pages->fetch_assoc(); $total_pages = $row['num']; //if there's no page number, set it to the first page $stages = 3; $page = isset($_GET['page']) ? $_GET['page'] : 0; $start = empty($page) ? 0 : ($page - 1) * $limit; Should be done outside of the function. Then you can pass what the function needs to do its job. Logically a pagination function shouldn't have to worry about where the data is coming from. In your case it's bound strictly to a mysqli setup. If you wanted to reuse this function in another project later that didn't use mysqli you would have to rewrite the function. A function should have a single task; it shouldn't have to fetch the data itself and create the pagination links. By separating concerns in a way that a function only has a single task you write more flexible code, and that should always be your objective.
  11. Not sure what monkeytooth is talking about. You can do what you're trying to do like this: $filename = 'somename.txt'; $data =<<<DATA file data... DATA; header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . $filename); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . strlen($data)); echo $data; It's more or less the same thing, readfile just outputs the contents of the file, so you can just echo what you want the contents of the file to be. It's not like the browser knows if there's a real file on the server; it just gets the file data and the filename.
  12. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=306058.0
  13. That's because you're looping through the array in the wrong way. Each loop in $key will be 0, 1, 2, ... and $value will be an array. Instead try the loop I suggested before: $result = array(); foreach ($items as $item) { if (strpos(strtolower($item[0]), $text) !== false) { array_push($result, array("id"=>$item[1], "label"=>$item[0], "value" => strip_tags($item[0]))); } if (count($result) > 11) break; } or change the way the $items array is constructed like jcbones suggested.
  14. Your code doesn't really make much sense, and I'm not really sure what you're trying to do. Take this part for example: $etime_who = $usr_filenumber; # Filenumber used to identify user being viewed. Used in function call. ?> <script language="javascript" type="text/javascript"> var etimeuser = "<?php echo $etime_who; ?>"; var etimeold = "<?php echo $usr_filenumber; ?>"; $etime_who and $usr_filenumber contain the same thing, so you're passing the same value to the function in 2 parameters.
  15. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=306005.0
  16. By the way, there's a topic solved feature. When your problems get solved it's appreciated if you mark them as such. There's a button on the bottom left to do so, thanks.
  17. Use single quotes on this echo. If you're using double quotes then you need to escape all the double quotes inside of it. Much easier to just use single quotes: echo ' <ul> <li class="m1"><a href="../home.html" class="active">Home</a></li> HERE!!!!!!!!! <li class="m2"><a href="../about-us.html">About</a></li> <li class="m3"><a href="../services.html">Services</a></li> <li class="m4"><a href="../support.html">Support</a></li> <li class="m5"><a href="../contact-us.html">contacts</a></li> <li class="m6"><a href="../sitemap.html">Sitemap</a></li> </ul> ';
  18. Before the foreach() place this: echo "<pre>" . print_r($items, true) . "</pre>"; and post the output. Edit: Why are you defining your own function to convert the array to a JSON representation? Why don't you just use json_encode?
  19. Try this: $result = array(); foreach ($items as $item) { if (strpos(strtolower($item[0]), $text) !== false) { array_push($result, array("id"=>$item[1], "label"=>$item[0], "value" => strip_tags($item[0]))); } if (count($result) > 11) break; }
  20. The DOM has no idea that PHP generated the HTML, it isn't concerned. PHP just outputs the HTML and sends to the browser. So whether it's hard-coded or generated from PHP as long as the output is correct it will work. I'm guessing your PHP is either generating malformed HTML so your elements aren't be created properly, or the ids aren't what you're expecting. What you should do is look at the HTML output from your PHP file to see what's wrong. I'm not sure why you're using a do..while() loop. That doesn't really make much sense: the first loop $res will be undefined.
  21. phpinfo We're just checking to make sure you have PHP installed and it's working.
  22. Are you sure you have PHP installed? If you create a new file containing the following does it work?: <?php phpinfo(); ?>
  23. Hard-coding the ids of the elements or having PHP generate them makes no difference to JavaScript. You must be doing something else wrong, and we can't really help without more relevant information.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.