Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Everything posted by HuggieBear

  1. If your passing integers then there's no need for the single quotes. Regards Huggie
  2. No problem Mark, glad to have been of assistance. Regards Huggie
  3. I'll code you a full example.  Give me half an hour. Regards Huggie
  4. Not quite, this would... $PHP_SELF?page=$pageprev&airline_search=$airline_search&aircraft_search=$aircraft_search&location_search=$location_search&keyword_search=$keyword_search Regards Huggie
  5. You aren't defining $sid anywhere. You have $pid defined ok, but not $sid. Regards Huggie
  6. [quote]Good point huggie, I didn't notice that, still don't[/quote] A quick look at the query string to navigate between pages, shows that the variables being passed are $limit and $page.  Yet a search for $_GET['limit'] or $_GET['page'] in the code yields no results, implying that the original coder is relying on 'Register Globals' being switched on. Then look at what the user says... [quote]when i click on e.g. 'show 20 results per page' it still only shows the default 10 results.  also when i click on next page or 'page 3' it still only shows the first 10 results[/quote] This gives the game away totally, despite having the value in the string, the query isn't picking it up, it's applying the default every time meaning it's not getting to the script. Regards Huggie
  7. Give this a try... [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <?php include ("**********"); $limit = isset($_GET['limit']) ? $_GET['limit'] : '10'; // Default results per-page. $page = isset($_GET['page']) ? $_GET['page'] : '0' // Default page value. $query='Personal Care'; $numresults = mysql_query("SELECT * FROM stock where category2='". $query ."'"); // the query. $numrows = mysql_num_rows($numresults); // Number of rows returned from above query. if ($numrows == 0){ echo("No results found matching your query - $query"); // bah, modify the "Not Found" error for your needs. exit();} $pages = intval($numrows/$limit); // Number of results pages. // $pages now contains int of pages, unless there is a remainder from division. if ($numrows%$limit) { $pages++;} // has remainder so add one page $current = ($page/$limit) + 1; // Current page number. if (($pages < 1) || ($pages == 0)) { $total = 1;} // If $pages is less than one or equal to 0, total pages is 1. else { $total = $pages;} // Else total pages is $pages value. $first = $page + 1; // The first result. if (!((($page + $limit) / $limit) >= $pages) && $pages != 1) { $last = $page + $limit;} //If not last results page, last result equals $page plus $limit. else{ $last = $numrows;} // If last results page, last result equals total number of results. //escape from PHP mode. ?> <head> <html><title>Search Results for <?=$query?></title> <style type="text/css"> <!-- .style1 { color: #FF0000; font-weight: bold; } --> </style> </head> <body> <center><h2>Search Results for <?=$query?></h2></center> <table width="100%" border="0"> <tr>   <td width="50%" align="left"> Results <b><?=$first?></b> - <b><?=$last?></b> of <b><?=$numrows?></b>   </td>   <td width="50%" align="right"> Page <b><?=$current?></b> of <b><?=$total?></b>   </td> </tr> <tr>   <td colspan="2" align="right">&nbsp;   </td> </tr> <tr>   <td colspan="2" align="right"> Results per-page: <a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=5">5</a> | <a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=10">10</a> | <a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=20">20</a> | <a href="<?=$PHP_SELF?>?query=<?=$query?>&page=<?=$page?>&limit=50">50</a>   </td> </tr> </table> <? //Go back into PHP mode. // Now we can display results. $results = mysql_query("select * from stock where category2='". $query ."' order by Prod_IntPartNo ASC LIMIT $page, $limit"); while ($row = mysql_fetch_array($results)){ ?> <table width="477" height="167" border="0" align="center" cellpadding="0" cellspacing="0">       <tr>         <td colspan="2" bgcolor="#FECD18"><strong><?=$row["pagename"]?></strong></td>       </tr>           <tr>         <td width="180" rowspan="5"><img src="images/Stock/PRODUCT_<?=$row["Prod_IntPartNo"]?>_THUMB.jpg"></td>         <td width="203"></td>       </tr>       <tr>         <td height="27" class="style7 main"><strong>Product Code: <?=$row["Prod_IntPartNo"]?> </strong></td>       </tr>       <tr>         <td height="29" class="style7 main"><strong>Brand:</strong></td>       </tr>       <tr>         <td height="35"><span class="style6 style1">RRP: £<?=$row["rrp"]?></span></td>       </tr>       <tr>         <td>&nbsp;</td>       </tr> </table> <? } ?> <p align="center"> <? if ($page != 0) { // Don't show back link if current page is first page. $back_page = $page - $limit; echo("<a href=\"$PHP_SELF?query=$query&page=$back_page&limit=$limit\">back</a>    \n");} for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it. { $ppage = $limit*($i - 1); if ($ppage == $page){ echo("<b>$i</b> \n");} // If current page don't give link, just text. else{ echo("<a href=\"$PHP_SELF?query=$query&page=$ppage&limit=$limit\">$i</a> \n");} } if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // If last page don't give next link. $next_page = $page + $limit; echo("    <a href=\"$PHP_SELF?query=$query&page=$next_page&limit=$limit\">next</a>\n");} ?> </p> </body> </html>[/code] Regards Huggie
  8. This looks as though it could be a problem with a setting called 'Register Globals'. Regards Huggie
  9. [quote author=davieboy link=topic=123520.msg511347#msg511347 date=1169564328] ok, im a little confused. sorry. do i then jsut do my search page links like searh.php?page=2&airline=$airline will that not still have the '&airline' in it even if 'airline_search' is not set? [/quote] Yes, that's correct, hence always having a default value. Regards Huggie
  10. OK, try this... [code]<?php $array = file("posts.txt"); foreach ($array as $line) {   list($k, $v) = explode("#", $line);   $array1[$k] = $v; } print_r(array_keys($array1, "2")); ?>[/code] Regards Huggie
  11. Ted, remember what I advised last time?  Take a little time explaining your posts well and you're bound to get a better response. The following doesn't make sense, are you sure you haven't missed off the middle of the sentence? [quote]This gives the line number of the txt file, in my eg. i used 2 so i want it to echo 1 as in line 2[/quote]  :-\ Regards Huggie
  12. You set a default.  So the top of your page looks something like this: [code]<?php $airline_search = !empty($_GET['airline_search']) ? $_GET['airline_search'] : 'ALL'; $airport_search = !empty($_GET['airport_search']) ? $_GET['airport_search'] : 'ALL'; $aircraft_search = !empty($_GET['aircraft_search']) ? $_GET['aircraft_search'] : 'ALL'; $keyword_search = !empty($_GET['keyword_search']) ? $_GET['keyword_search'] : 'ALL'; ?>[/code] Regards Huggie
  13. I'd say Cep's method is the most widely used. This can be achieved with [url=http://uk.php.net/manual/en/ref.session.php]$_SESSION[/url] variables. Regards Huggie
  14. They need to be passed in the URL ideally. [code]<a href="pagename.php?page=2&airline_search=$airline_search">Page 2</a>[/code] Regards Huggie
  15. It's not relating to the pagination constraints.  It's because you're not submitting a valid query. The SELECT syntax has to follow a specific order, ORDER BY must come after WHERE, try it this way: [code] <?php $query  = "SELECT * FROM photos WHERE status = 'accepted'"; if (!empty($airline_search)){   $query .= " AND airline LIKE '%$airline_search%'"; } if (!empty($airport_search)){   $query .= " AND location LIKE '%$airport_search%'"; }        if (!empty($aircraft_search)){   $query .= " AND aircraft LIKE '%aircraft_search%'"; } if (!empty($keyword_search)) {   $query .= " AND comments LIKE '%keyword_search%'"; } $query .= " ORDER by ID LIMIT $limitvalue, $limit"; ?> [/code] Regards Huggie
  16. OK, did you write this code yourself or did a lot of it come from a different location, as you have mixed standards. In some places you're using $_POST and in others $HTTP_POST_VARS.  These are different standards for achieving the same thing, so something has gotten mixed up along the way. I'm not saying this is the problem, as the two can work happily alongside each other, but it does help to gauge how much you've changed the script if you didn't write it originally yourself. Regards Huggie
  17. Jesi, that won't yield the same results.  He'll need to constrcut the string as he goes. Something like this [code] <?php $sql = "SELECT * FROM photos WHERE 1=1 "; if (!empty($airline_search)){   $sql .= "AND airline LIKE '%$airline_search%' "; } if (!empty($airport_search)){   $sql .= "AND location LIKE '%$airport_search%' "; } ?> [/code] Regards Huggie
  18. OK, firstly, php is case-sensitive, so on page two (databox2.php) change [code=php:0]<?PHP[/code] to [code=php:0]<?php[/code] and then try again :) Regards Huggie
  19. Try changing this: [code]<img src= <?php echo= $target_path ?> picture="" border="0" height="100" width="90">[/code] To this: [code]<img src="<?php echo $target_path; ?>" picture="" border="0" height="100" width="90">[/code] Also, this code doesn't look correct... [code]<a href='../page_g/etc/{$target_path['basename']}[/code] as $target_path is not an array. Regards Huggie
  20. As far as I know, it can read them, but can't server them, hence being "Outside" the webroot. There's no point in having private directories outside the webroot if they can be accessed from the web, kind of defeats the objective, don't you think :) Regards Huggie
  21. If you have your base query as... [color=green]SELECT column_name FROM table_name WHERE 1=1[/color] This is the same as... [color=green]SELECT column_name FROM table_name[/color] But it means that you know there's always going to be an AND or && before anything you add, it saves working out if it's the first result in the array or not. Regards Huggie
  22. I'm just off to bed and will take another look at this tomorrow, but I'd say files is possibly the way to go here, depending of course on how many users you have and how long you want the persistent data for. Regards Huggie
  23. Are they only allowed one avatar? If so then when they register with the site, add their user details to the database and return the unique (auto-incremented) id that gets assigned to them by using [url=http://uk.php.net/manual/en/function.mysql-insert-id.php]mysql_insert_id()[/url]. Then maybe use that value to name their avatar.  All avatars can be uploaded to the same directory, there's never going to be a clash as no user can have the same id. Regards Huggie
  24. There's nothing wrong with this code, it's displaying Wed 17th Jan 2007 for me. Regards Huggie
  25. I'd create a directory based on their unique UserID when they sign up, then when they login, place their unique id into a session variable and use it when uploading files. Regards Huggie
×
×
  • 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.