
andy_b_1502
Members-
Posts
397 -
Joined
-
Last visited
Everything posted by andy_b_1502
-
everyone goes mental when i do this but here goes: <?PHP include ('php only scripts/db.php'); error_reporting(E_ALL); ?> <!DOCTYPE html> <head> <title>Removals | Removalspace.com</title> <style type="text/css"> <!-- body { background-image: url(styles/downloaded%20styles/todo/todo/images/bg.png); } --> </style> <link href="styles/downloaded styles/todo/todo/css/style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/style9.css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/demo.css" /> <link href='http://fonts.googleapis.com/css?family=Terminal+Dosis' rel='stylesheet' type='text/css' /> <style type="text/css"> <!-- .Stile1 {color: #333333} .aa { font-size: 13px; } #container header nav #logo p .cursive { font-size: 9px; } #apDiv1 { position:absolute; width:466px; height:24px; z-index:1; left: 585px; top: 191px; } --> </style> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-31656176-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <style type="text/css"> <!-- .pagNumActive { color: #000; border:#060 1px solid; background-color: #D2FFD2; padding-left:3px; padding-right:3px; } .paginationNumbers a:link { color: #000; text-decoration: none; border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px; } .paginationNumbers a:visited { color: #000; text-decoration: none; border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px; } .paginationNumbers a:hover { color: #000; text-decoration: none; border:#060 1px solid; background-color: #D2FFD2; padding-left:3px; padding-right:3px; } .paginationNumbers a:active { color: #000; text-decoration: none; border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px; } #apDiv2 { position:absolute; width:587px; height:40px; z-index:1; left: 261px; top: 541px; } --> </style> </head> <body> <!--start container --> <div id="container"> <header> <nav> <div id="apDiv1"><span class="cursive">Upagrade Now For Your Logo Here!</span></div> <div id="logo"> <p><a href="index.php"><img src="images/header2.png" alt="Logo here" width="219" height="161" /></a></p> <p><span class="cursive">Company Logo's/Upgraded UK Listings Shown Below (enter your postcode for your area)</span></p> <p> </p> <p>click <a href="register00.php">here</a> to add your company</p> </div> <div id="search-top"><img src="styles/downloaded styles/todo/todo/images/quote-right.png" alt="images" /><span class="cursive">Enter your postcode here</span><img src="styles/downloaded styles/todo/todo/images/quote-left.png" alt="images" /> <form method="post" action="search.php"> <input type="text" name="strSearch" onFocus="if(this.value=='Search Area')this.value='';" onBlur="if(this.value=='')this.value='Search Area';" value="Search Area" id="search-field"/> <input type="submit" value="" id="search-btn"/> </form> </div> <div id="nav_social"><a href="http://www.facebook.com/pages/Removalspace/181434181939226"><img src="styles/downloaded styles/todo/todo/images/facebook_32.png" alt="Become a fan" width="32" height="32" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/twitter_32.png" alt="Follows on Twitter" /></a><a href="id=183427956&trk=tab_pro"><img src="styles/downloaded styles/todo/todo/images/linkedin_32.png" alt="Linked in" /></a><a href="contact.php"><img src="styles/downloaded styles/todo/todo/images/email_32.png" alt="Contact" width="32" height="32" /></a><!-- Place this tag where you want the +1 button to render --> <g:plusone size="small" annotation="inline"></g:plusone> <!-- Place this render call where appropriate --> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script></div> </nav> </header> <p><figure><a href="removals.php">Search Removals</a></figure> |</p> <p><figure><a href="storage.php">Search Storage</a></figure> |</p> <p><figure><a href="register00.php">Add Listing</a></figure> |</p> <p><figure><a href="about.php">About</a></figure> |</p> <p><figure><a href="contact.php">Contact</a></figure> |</p> <p><figure><a href="login00.php">Login</a></figure></p> <div class="content"> <!--star main --> <main> <?php $query = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC"; if ($result = mysql_query($query)); $what_services = "R"; $row = mysql_fetch_array($result); $approved = $row['approved']; if(isset($_GET['pn'])){ $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); }else{ $pn = 1; } $itemsPerPage = 10; $nr = ('nr'); $lastPage = ceil($nr / $itemsPerPage); if($pn < 1){ $pn = 1; }else if($pn > $lastPage){ $pn = $lastPage; } // This creates the numbers to click in between the next and back buttons $centerPages = ""; // Initialize this variable $sub1 = $pn - 1; $sub2 = $pn - 2; $add1 = $pn + 1; $add2 = $pn + 2; if ($pn == 1) { $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } else if ($pn == $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; } else if ($pn > 2 && $pn < ($lastPage - 1)) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a> '; } else if ($pn > 1 && $pn < $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } // This line sets the "LIMIT" range... the 2 values we place to choose a range of rows from database in our query $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; // Now we are going to run the same query as above but this time add $limit onto the end of the SQL syntax // $sql2 is what we will use to fuel our while loop statement below $sql2 = mysql_query("SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"); //////////////////////////////// END Adam's Pagination Logic /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////// Adam's Pagination Display Setup /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $paginationDisplay = ""; // Initialize the pagination output variable // This code runs only if the last page variable is not equal to 1, if it is only 1 page we require no paginated links to display if ($lastPage != "1"){ // This shows the user what page they are on, and the total number of pages $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. '<img src="images/clearImage.gif" width="48" height="1" alt="Spacer" />'; // If we are not on page 1 we can place the Back button if ($pn != 1) { $previous = $pn - 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> '; } // Lay in the clickable numbers display here between the Back and Next links $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>'; // If we are not on the very last page we can place the Next button if ($pn != $lastPage) { $nextPage = $pn + 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> '; } } ///////////////////////////////////// END Adam's Pagination Display Setup /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $sql2 = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"; if( $result = mysql_query($query)); while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; $what_services = $what_services; SWITCH ($approved) { case 0: break; case 1: ?> <div class="abox"> <figure> <fcapion> <p> </p> <p><?PHP echo $row['company_name']; ?></p> <p> </p> </figure> </div> <div class="abox"> <figure> <fcapion> </fcaption> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> </figure> </div> <div class="abox"> <figure> <fcapion> <p> </p> <h1><?PHP echo $row['company_name']; ?></h1> <p> </p> </figure> </div> <p> <?PHP break; case 2: ?> </p> <div class="abox"> <figure> <fcapion> <p> </p> <p><?PHP echo $row['company_name']; ?> </p> <p> </p> </figure> </div> <div class="abox"> <figure> <fcapion> </fcaption> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> </figure> </div> <div class="abox"> <figure> <fcapion> <p> </p> <h1><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></h1> <p> </p> </figure> </div> <?PHP break; case 3: ?> <div class="abox"> <figure> <fcapion> <p> </p> <p><a href="view00.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $row['company_name']; ?></a></p> <p> </p> </figure> </div> <div class="abox"> <figure> <fcapion> <p> </p> <p><a href="view00.php?id=<?PHP echo $row['id']; ?>"> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] . "<br>mobile/other: " . $row['phone'] ?> </a></p> <p> </p> </figure> </div> <div class="abox"> <figure> <fcapion> <h1>click logo to read more...<a href="view00.php?id=<?PHP echo $row['id']; ?>"><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></a></h1> </figure> </div> <p> </p> <p> <?PHP break; } } ?> </p> </main> <!--end main --> <!--start middle --> </div> <!--end middle --> <!--start footer --> <footer> <div style="margin-left 58px, margin-right 58px, padding 6px border #999, 1px solid"><?php echo $paginationDisplay;?></div> <div id="footer"> <div id="footerleft"> <h2>removalspace</h2> <ul> <li><a href="contact.php">Contact</a></li> <li><a href="about.php">About Us</a></li> <li><a href="other-info.php">Other</a></li> <li></li> </ul> </div> <div id="footermiddle"> <h2>User Comments</h2> <ul> <li><a href="#">Read Reviews</a></li> <li><a href="contact.php">Leave A Comment</a></li> <li><a href="#">Read Blogs</a></li> <li></li> </ul> </div> <div id="footerright"> <h2>our mission</h2> <ul> <li><a href="about.php">Who Are We?</a></li> <li><a href="about.php">What We Do</a></li> <li><a href="about.php">Our Mission</a></li> <li></li> </ul> </div> <details> <summary> <p><a href="http://www.imediacreatives.it" target="_blank">Imediacreatives.it</a><a href="http://freehtml5templates.com">Designers</a> Copyright © removalspace.com -2012.</p></summary><p></p> </details> </div> </footer> <!--end footer --> </div> <!--end container --> </body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> </html>
-
Okay thanks, changed that but it displayed ALL my results not 10 per page? doesn't $limit do that?
-
Both of you are right, i didn't quite understand the define function and had to ask for help, yes i ignored the answers before because of this... I think it was constructive... In light of this, i have broken it down and read about define, I have made the first querie(s) error's correct and am getting it, however using the same way for query 2 ($sql2) i still have one error left to solve, this i don't understand how? it is a Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in error. This is the code with the error my fetch_array: $result = ('result'); $result = mysql_query("SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"); while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; $what_services = $what_services; The result resource is the query which is defined above it. Can you please explain why one works and the other doesn't? Just for reference the first query: $result = ('result'); $result = mysql_query("SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC"); $what_services = "R"; $row = mysql_fetch_array($result); $approved = $row['approved']; Thank you in advance
-
Yeah i just selected out the php to show you lot on here and left the html... so... i define result like this: $result = mysql_query($query); query is this: $query = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC"; so the full snippet looks like this now: <?php $result = mysql_query($query); $row = mysql_fetch_array($result); $what_services = "R"; $approved = $row['approved']; $query = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC"; what have i done wrong? it's not sinking in, sorry.
-
I was advised to make a new thread, the problem is i have a few error messages with this code: <?PHP include ('php only scripts/db.php'); error_reporting(E_ALL); ?> <?php $row = mysql_fetch_array($result); $what_services = "R"; $approved = $row['approved']; $query = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC"; $result = mysql_query($query); if(isset($_GET['pn'])){ $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); }else{ $pn = 1; } $itemsPerPage = 10; $lastPage = ceil($nr / $itemsPerPage); if($pn < 1){ $pn = 1; }else if($pn > $lastPage){ $pn = $lastPage; } // This creates the numbers to click in between the next and back buttons $centerPages = ""; // Initialize this variable $sub1 = $pn - 1; $sub2 = $pn - 2; $add1 = $pn + 1; $add2 = $pn + 2; if ($pn == 1) { $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } else if ($pn == $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; } else if ($pn > 2 && $pn < ($lastPage - 1)) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a> '; } else if ($pn > 1 && $pn < $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } // This line sets the "LIMIT" range... the 2 values we place to choose a range of rows from database in our query $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; // Now we are going to run the same query as above but this time add $limit onto the end of the SQL syntax // $sql2 is what we will use to fuel our while loop statement below $sql2 = mysql_query("SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"); //////////////////////////////// END Adam's Pagination Logic /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////// Adam's Pagination Display Setup /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $paginationDisplay = ""; // Initialize the pagination output variable // This code runs only if the last page variable is not equal to 1, if it is only 1 page we require no paginated links to display if ($lastPage != "1"){ // This shows the user what page they are on, and the total number of pages $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. '<img src="images/clearImage.gif" width="48" height="1" alt="Spacer" />'; // If we are not on page 1 we can place the Back button if ($pn != 1) { $previous = $pn - 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> '; } // Lay in the clickable numbers display here between the Back and Next links $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>'; // If we are not on the very last page we can place the Next button if ($pn != $lastPage) { $nextPage = $pn + 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> '; } } ///////////////////////////////////// END Adam's Pagination Display Setup /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; $what_services = $what_services; $result = mysql_query($sql2); SWITCH ($approved) { case 0: break; case 1: ?> <?PHP echo $row['company_name']; ?> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> <?PHP echo $row['company_name']; ?> <?PHP break; case 2: ?> <?PHP echo $row['company_name']; ?> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> <img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/> <?PHP break; case 3: ?> <a href="view00.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $row['company_name']; ?></a> <a href="view00.php?id=<?PHP echo $row['id']; ?>"> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] . "<br>mobile/other: " . $row['phone'] ?> </a> <a href="view00.php?id=<?PHP echo $row['id']; ?>"><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></a> <?PHP break; } } ?> the errors are: " Notice: Undefined variable: result in /hermes/bosoraweb023/b109/ipg.removalspacecom/test.php on line 138 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hermes/bosoraweb023/b109/ipg.removalspacecom/test.php on line 138 Notice: Undefined variable: nr in /hermes/bosoraweb023/b109/ipg.removalspacecom/test.php on line 152 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hermes/bosoraweb023/b109/ipg.removalspacecom/test.php on line 209" Can someone help please?
-
i don't understand why the display area with the buttons for the user to choose which page has got a 0 and a -1 This bit of code should keep it at page 1 shouldn't it: if($pn < 1){ $pn = 1; }else if($pn > $lastPage){ $pn = $lastPage; } does anybody know why this is happening? Thanks
-
http://www.removalspace.com/removals.php?pn=-1 this i after i added: $result = mysql_query($sql2); How do i get it to display 10 items per page and at least show more than 1 result all together??
-
$result = mysql_query($query); whats that then?
-
just so i'm getting it right, it should be: $row = "approved"; to define? if so i'm getting error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /hermes/bosoraweb023/b109/ipg.removalspacecom/test2.php on line 12 Warning: implode() [function.implode]: Argument must be an array in /hermes/bosoraweb023/b109/ipg.removalspacecom/test2.php on line 12 Pages: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hermes/bosoraweb023/b109/ipg.removalspacecom/test2.php on line 29 ?> i have an array?
-
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /hermes/bosoraweb023/b109/ipg.removalspacecom/test2.php on line 12 Warning: implode() [function.implode]: Argument must be an array in /hermes/bosoraweb023/b109/ipg.removalspacecom/test2.php on line 12 Pages:
-
<?PHP session_start(); include ('php only scripts/db.php'); error_reporting(E_ALL); ini_set("display_errors", 1); $what_services = "R"; $approved = "approved"; //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($pagenum))) { $pagenum = 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC") or die(mysql_error()); $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; $what_services = $row['what_services']; SWITCH ($approved) { case 0: break; case 1: ?> <?PHP echo $row['company_name']; ?></p> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> </figure> <?PHP echo $row['company_name']; ?> <?PHP break; case 2: ?> <?PHP echo $row['company_name']; ?> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> <img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/> <?PHP break; case 3: ?> <a href="view00.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $row['company_name']; ?></a> <a href="view00.php?id=<?PHP echo $row['id']; ?>"> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] . "<br>mobile/other: " . $row['phone'] ?></a> click logo to read more...<a href="view00.php?id=<?PHP echo $row['id']; ?>"><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></a> <?PHP break; } } ?> The im getting the error: "Notice: Undefined variable: result in /hermes/bosoraweb023/b109/ipg.removalspacecom/test2.php on line 68 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hermes/bosoraweb023/b109/ipg.removalspacecom/test2.php on line 68" But i define it here $what_services = "R"; $approved = "approved"; could someone please help me to define it properly or help with the correct way to do this please?
-
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
} else { // If the pn URL variable is not present force it to be value of page number 1 $pn = 1; } doesn't that do what it say's force it to be number 1? //This is where we set how many database items to show on each page $itemsPerPage = 10; i don't understand why $itemsPerPage wouldn't be set? -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
testing this code it works fine, so why doesn't it with the full code? its something to do with the either limit or the second query? <?PHP session_start(); include ('php only scripts/db.php'); $query2 = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC"; $result2 = mysql_query($query2); echo $query2; echo mysql_error(); ?> -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC LIMIT 0,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 '' at line 1 <?PHP session_start(); include ('php only scripts/db.php'); $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; $query2 = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"; $result2 = mysql_query($query2); echo $query2; echo mysql_error(); ?> -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
I uploaded and tested this: <?PHP include ('php only scripts/db.php'); $query2 = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC, $limit"; $result2 = mysql_query($query2); echo('$query2'); echo mysql_error(); ?> and get this error: $query2You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Which doesn't tell me much? is there a code for more detail? -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
i have done as suggested, made the while statement have the correct result resource but i'm getting the invalid resource error? Can somebody please help? -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
its not working? i get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hermes/bosoraweb023/b109/ipg.removalspacecom/removals.php on line 208 after changing the result resource to this: <?php while ( $row = mysql_fetch_array($result2)) { $approved = $row['approved']; $what_services = $row['what_services']; ?> and 2nd query this: $query2 = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"; $result2 = mysql_query($query2); -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
it does go in between the query and the while loop though, right?? -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
so how can i rectify it? by swapping the two over? i changed this line $sql2 = mysql_query("SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"); to $query = mysql_query("SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"); and $result = mysql_query("SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"); but only one worked (result) but still gave all the listings on one page, i don't get it? -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
Can someone please help me, the limit value (set by 10 results per page) isn't working, it's showing everything in the table on one page? <?PHP session_start(); include ('php only scripts/db.php'); ?> <!DOCTYPE html> <head> <title>Removals | Removalspace.com</title> <style type="text/css"> <!-- body { background-image: url(styles/downloaded%20styles/todo/todo/images/bg.png); } --> </style> <link href="styles/downloaded styles/todo/todo/css/style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/style9.css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/demo.css" /> <link href='http://fonts.googleapis.com/css?family=Terminal+Dosis' rel='stylesheet' type='text/css' /> <style type="text/css"> <!-- .Stile1 {color: #333333} .aa { font-size: 13px; } #container header nav #logo p .cursive { font-size: 9px; } #apDiv1 { position:absolute; width:466px; height:24px; z-index:1; left: 585px; top: 191px; } --> </style> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-31656176-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <style type="text/css"> <!-- .pagNumActive { color: #000; border:#060 1px solid; background-color: #D2FFD2; padding-left:3px; padding-right:3px; } .paginationNumbers a:link { color: #000; text-decoration: none; border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px; } .paginationNumbers a:visited { color: #000; text-decoration: none; border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px; } .paginationNumbers a:hover { color: #000; text-decoration: none; border:#060 1px solid; background-color: #D2FFD2; padding-left:3px; padding-right:3px; } .paginationNumbers a:active { color: #000; text-decoration: none; border:#999 1px solid; background-color:#F0F0F0; padding-left:3px; padding-right:3px; } #apDiv2 { position:absolute; width:587px; height:40px; z-index:1; left: 261px; top: 541px; } --> </style> </head> <body> <!--start container --> <div id="container"> <header> <nav> <div id="apDiv1"><span class="cursive">Upagrade Now For Your Logo Here!</span></div> <div id="logo"> <p><a href="index.php"><img src="images/header2.png" alt="Logo here" width="219" height="161" /></a></p> <p><span class="cursive">Company Logo's/Upgraded UK Listings Shown Below (enter your postcode for your area)</span></p> <p> </p> <p>click <a href="register00.php">here</a> to add your company</p> </div> <div id="search-top"><img src="styles/downloaded styles/todo/todo/images/quote-right.png" alt="images" /><span class="cursive">Enter your postcode here</span><img src="styles/downloaded styles/todo/todo/images/quote-left.png" alt="images" /> <form method="post" action="search.php"> <input type="text" name="strSearch" onFocus="if(this.value=='Search Area')this.value='';" onBlur="if(this.value=='')this.value='Search Area';" value="Search Area" id="search-field"/> <input type="submit" value="" id="search-btn"/> </form> </div> <div id="nav_social"><a href="http://www.facebook.com/pages/Removalspace/181434181939226"><img src="styles/downloaded styles/todo/todo/images/facebook_32.png" alt="Become a fan" width="32" height="32" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/twitter_32.png" alt="Follows on Twitter" /></a><a href="id=183427956&trk=tab_pro"><img src="styles/downloaded styles/todo/todo/images/linkedin_32.png" alt="Linked in" /></a><a href="contact.php"><img src="styles/downloaded styles/todo/todo/images/email_32.png" alt="Contact" width="32" height="32" /></a><!-- Place this tag where you want the +1 button to render --> <g:plusone size="small" annotation="inline"></g:plusone> <!-- Place this render call where appropriate --> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script></div> </nav> </header> <p><figure><a href="removals.php">Search Removals</a></figure> |</p> <p><figure><a href="storage.php">Search Storage</a></figure> |</p> <p><figure><a href="register00.php">Add Listing</a></figure> |</p> <p><figure><a href="about.php">About</a></figure> |</p> <p><figure><a href="contact.php">Contact</a></figure> |</p> <p><figure><a href="login00.php">Login</a></figure></p> <div class="content"> <!--star main --> <main> <?php $what_services = "R"; $query = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC"; $result = mysql_query($query); if(isset($_GET['pn'])){ $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); }else{ $pn = 1; } $itemsPerPage = 10; $lastPage = ceil($nr / $itemsPerPage); if($pn < 1){ $pn = 1; }else if($pn > $lastPage){ $pn = $lastPage; } // This creates the numbers to click in between the next and back buttons $centerPages = ""; // Initialize this variable $sub1 = $pn - 1; $sub2 = $pn - 2; $add1 = $pn + 1; $add2 = $pn + 2; if ($pn == 1) { $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } else if ($pn == $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; } else if ($pn > 2 && $pn < ($lastPage - 1)) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a> '; } else if ($pn > 1 && $pn < $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } // This line sets the "LIMIT" range... the 2 values we place to choose a range of rows from database in our query $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; // Now we are going to run the same query as above but this time add $limit onto the end of the SQL syntax // $sql2 is what we will use to fuel our while loop statement below $sql2 = mysql_query("SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC $limit"); //////////////////////////////// END Adam's Pagination Logic /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////// Adam's Pagination Display Setup /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $paginationDisplay = ""; // Initialize the pagination output variable // This code runs only if the last page variable is not equal to 1, if it is only 1 page we require no paginated links to display if ($lastPage != "1"){ // This shows the user what page they are on, and the total number of pages $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. '<img src="images/clearImage.gif" width="48" height="1" alt="Spacer" />'; // If we are not on page 1 we can place the Back button if ($pn != 1) { $previous = $pn - 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> '; } // Lay in the clickable numbers display here between the Back and Next links $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>'; // If we are not on the very last page we can place the Next button if ($pn != $lastPage) { $nextPage = $pn + 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> '; } } ///////////////////////////////////// END Adam's Pagination Display Setup /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; $what_services = $row['what_services']; SWITCH ($approved) { case 0: break; case 1: ?> <div class="abox"> <figure> <fcapion> <p> </p> <p><?PHP echo $row['company_name']; ?></p> <p> </p> </figure> </div> <div class="abox"> <figure> <fcapion> </fcaption> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> </figure> </div> <div class="abox"> <figure> <fcapion> <p> </p> <h1><?PHP echo $row['company_name']; ?></h1> <p> </p> </figure> </div> <p> <?PHP break; case 2: ?> </p> <div class="abox"> <figure> <fcapion> <p> </p> <p><?PHP echo $row['company_name']; ?> </p> <p> </p> </figure> </div> <div class="abox"> <figure> <fcapion> </fcaption> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> </figure> </div> <div class="abox"> <figure> <fcapion> <p> </p> <h1><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></h1> <p> </p> </figure> </div> <?PHP break; case 3: ?> <div class="abox"> <figure> <fcapion> <p> </p> <p><a href="view00.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $row['company_name']; ?></a></p> <p> </p> </figure> </div> <div class="abox"> <figure> <fcapion> <p> </p> <p><a href="view00.php?id=<?PHP echo $row['id']; ?>"> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] . "<br>mobile/other: " . $row['phone'] ?> </a></p> <p> </p> </figure> </div> <div class="abox"> <figure> <fcapion> <h1>click logo to read more...<a href="view00.php?id=<?PHP echo $row['id']; ?>"><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></a></h1> </figure> </div> <p> </p> <p> <?PHP break; } } ?> </p> </main> <!--end main --> <!--start middle --> </div> <!--end middle --> <!--start footer --> <footer> <div style="margin-left 58px, margin-right 58px, padding 6px border #999, 1px solid"><?php echo $paginationDisplay;?></div> <div id="footer"> <div id="footerleft"> <h2>removalspace</h2> <ul> <li><a href="contact.php">Contact</a></li> <li><a href="about.php">About Us</a></li> <li><a href="other-info.php">Other</a></li> <li></li> </ul> </div> <div id="footermiddle"> <h2>User Comments</h2> <ul> <li><a href="#">Read Reviews</a></li> <li><a href="contact.php">Leave A Comment</a></li> <li><a href="#">Read Blogs</a></li> <li></li> </ul> </div> <div id="footerright"> <h2>our mission</h2> <ul> <li><a href="about.php">Who Are We?</a></li> <li><a href="about.php">What We Do</a></li> <li><a href="about.php">Our Mission</a></li> <li></li> </ul> </div> <details> <summary> <p><a href="http://www.imediacreatives.it" target="_blank">Imediacreatives.it</a><a href="http://freehtml5templates.com">Designers</a> Copyright © removalspace.com -2012.</p></summary><p></p> </details> </div> </footer> <!--end footer --> </div> <!--end container --> </body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> </html> -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
thought i best put the full code here. it doesn't seem to be there yet 18615_.php -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
Thanks Barand, it's a really good tutorial, I have been working through it and adding bits and bobs from the source file, do i have to change the 2nd query in my script in any way for it to work properly with my original script i had? In the tutorial it has query2 in his while loop, in my original i have while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; $what_services = $row['what_services']; -
how to split results into page 1,2,3 etc...
andy_b_1502 replied to andy_b_1502's topic in PHP Coding Help
forgot to make a link for you to see what i mean: http://www.removalspace.com/removals.php -
Hello, I have a code to display results on my website from mySQL table, there is a rising number of results being added daily which is great but rather than displaying a full list i'd like them to be separated into pages but have no idea how to split them up into say 50 per page. Each added listing has to be approved by admin and the code displays by approved status like this: <?PHP session_start(); include ('php only scripts/db.php'); ?> <?php $what_services = "R"; $query = "SELECT * FROM companies WHERE what_services IN('R','B') ORDER BY approved DESC, company_name ASC"; $result = mysql_query($query); while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; $what_services = $row['what_services']; SWITCH ($approved) { case 0: break; case 1: ?> <?PHP echo $row['company_name']; ?> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> <?PHP echo $row['company_name']; ?> <?PHP break; case 2: ?> <?PHP echo $row['company_name']; ?> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] ?> <img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/> <?PHP break; case 3: ?> <a href="view00.php?id=<?PHP echo $row['id']; ?>"><?PHP echo $row['company_name']; ?></a> <a href="view00.php?id=<?PHP echo $row['id']; ?>"> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] . "<br>mobile/other: " . $row['phone'] ?> </a> click logo to read more...<a href="view00.php?id=<?PHP echo $row['id']; ?>"><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></a> <?PHP break; } } ?> The switch sorts the approved, i just dont want all the results displayed in one massive list as the site is expected to have at least 5000 listings on it :-\
-
Thank you, and everyone for helping me.