PHP - After Adding Isset($_get Pagination Not Working
soory guys .. actually i am trying to add pagination in script.. but its not pagging.
but when i tried without isset($_get the code worked fine and then i tried to doing with isset($_get for a perticular cat
but its not working. can someone see my code and tell me whats worng i have done.
<!DOCTYPE HTML> <html> <head> </head> <body> <?php // include database connection include 'libs/db_connect.php'; // page is the current page, if there's nothing set, default is page 1 $page = isset($_GET['page']) ? $_GET['page'] : 1; // set records or rows of data per page $recordsPerPage = 1; // calculate for the query LIMIT clause $fromRecordNum = ($recordsPerPage * $page) - $recordsPerPage; // select all data $query = "SELECT * FROM posts ORDER BY post_id desc LIMIT {$fromRecordNum}, {$recordsPerPage}"; /* page and its LIMIT clause looks like: 1 = 0, 5 2 = 5,10 3 = 10,15 4 = 15, 20 5 = 20, 25 */ $stmt = $con->prepare( $query ); $stmt->execute(); //this is how to get number of rows returned $num = $stmt->rowCount(); //check if more than 0 record found if($num>0){ $cat=1; if(isset($_GET['cat'])){ $cat_id = $_GET['cat']; $get_posts = "select * from posts where category_id = '$cat_id'"; $run_posts = mysql_query($get_posts); while($row_posts = mysql_fetch_array($run_posts)){ $post_id = $row_posts['post_id']; $post_title = $row_posts['post_title']; $post_date = $row_posts['post_date']; $post_author = $row_posts['post_author']; $post_image = $row_posts['image']; $post_content = substr($row_posts['post_content'],0,80); echo " <div class='post_area'> <h4> <a href = 'details.php?post=$post_id'>$post_title</a> </h4> <div class='date'><div id='com'> Date</div>$post_date</div><span style='font-size:12px'><i style='color:grey;font-size:10px'>Posted By</i> </b>$post_author</span> <content><img src = '123dondadatest/news_images/$post_image' width = '100' height='100'/> <div>$post_content <br/><a id='rmlink' href = 'details.php?post=$post_id'> Read More...</a></div><br /><br/><br/><br/> </div> "; } } // *************** <PAGING_SECTION> *************** echo "<div id='paging'>"; // ***** for 'first' and 'previous' pages if($page>1){ // ********** show the first page echo "<a href='" . $_SERVER['PHP_SELF'] . "' title='Go to the first page.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> << </span>"; echo "</a>"; // ********** show the previous page $prev_page = $page - 1; echo "<a href='" . $_SERVER['PHP_SELF'] . "?page={$prev_page}' title='Previous page is {$prev_page}.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> < </span>"; echo "</a>"; } // ********** show the number paging // find out total pages $query = "SELECT COUNT(*) as total_rows FROM posts"; $stmt = $con->prepare( $query ); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); $total_rows = $row['total_rows']; $total_pages = ceil($total_rows / $recordsPerPage); // range of num links to show $range = 2; // display links to 'range of pages' around 'current page' $initial_num = $page - $range; $condition_limit_num = ($page + $range) + 1; for ($x=$initial_num; $x<$condition_limit_num; $x++) { // be sure '$x is greater than 0' AND 'less than or equal to the $total_pages' if (($x > 0) && ($x <= $total_pages)) { // current page if ($x == $page) { echo "<span class='customBtn' style='background:red;'>$x</span>"; } // not current page else { echo " <a href='{$_SERVER['PHP_SELF']}?page=$x' class='customBtn'>$x</a> "; } } } // ***** for 'next' and 'last' pages if($page<$total_pages){ // ********** show the next page $next_page = $page + 1; echo "<a href='" . $_SERVER['PHP_SELF'] . "?page={$next_page}' title='Next page is {$next_page}.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> > </span>"; echo "</a>"; // ********** show the last page echo "<a href='" . $_SERVER['PHP_SELF'] . "?page={$total_pages}' title='Last page is {$total_pages}.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> >> </span>"; echo "</a>"; } echo "</div>"; // ***** allow user to enter page number echo "<form action='" . $_SERVER['PHP_SELF'] . "' method='GET'>"; echo "Go to page: "; echo "<input type='text' name='page' size='1' />"; echo "<input type='submit' value='Go' class='customBtn' />"; echo "</form>"; // *************** </PAGING_SECTION> *************** } // tell the user if no records were found else{ echo "<div class='noneFound'>No records found.</div>"; } ?> </body> </html> Similar TutorialsA few months ago, and a good amount of time before that, I had people telling me to use isset() instead of performing to see if the variable is empty, such as: !$_GET[''] I know the differences in the function and what they do, but when could isset() be used in a situation where it's better/more efficient then: !$_GET[''] I do use isset(), though. Hi, I'm new to php and am attempting to build a site where the navigation and content is built with query functions. My current tables in my database are Categories, Products, and Variation. So a person chooses a category -> then a product -> then a product page shows variations for that product. The problem I am currently having is after when a person selects a section the previous section selected is reset. So lets a person selects a category the product list is shown, but when a person selects a product, the category is no longer selected in the navigation. Or if someone selects product and sees all the variations, if he selects a variation the product ID is reset. I've tried to comb through the internet for some type of solution. I came across concatenating URL encode, but am not sure if this is the correct solution. I tried concatenating one of my urls with Code: [Select] "<a href=\"product_detail.php?cat=" . urlencode($sel_cat["id"]) . '&' . "product=" . urlencode($sel_product['id']) . '&' . "var=" . urlencode($var["id"]) . "\" its a bit of a stab in the dark. My $_GET function is Code: [Select] function find_selected_product() { global $sel_cat; global $sel_product; global $sel_var; if (isset($_GET['cat'])) { $sel_cat = get_cat_by_id($_GET['cat']); } elseif (isset($_GET['product'])) { $sel_cat = NULL; $sel_product = get_product_by_id($_GET['product']); } elseif (isset($_GET['product'])) { $sel_product = get_product_by_id($_GET['product']); $sel_var = get_default_var($sel_product['id']); } elseif (isset($_GET['var'])) { $sel_product = NULL; //test $sel_var = get_variation_by_id($_GET['var']); } else { $sel_cat = NULL; $sel_product = NULL; $sel_var = NULL; } } My navigation code is Code: [Select] function public_navigation($sel_cat, $public = true) { $output = "<td class=\"c1\"><div class=\"sidenav\"><ul>"; $cat_set = get_all_cats($public); while ($cat = mysql_fetch_array($cat_set)) { $output .= "<li>"; if ($cat["id"] == $sel_cat['id']) { $output .= "<a class=\"current\""; } $output .= "<a href=\"index.php?cat=" . urlencode($cat["id"]) . "\">{$cat["cat_name"]}</a></li>"; } $output .= "</ul>"; return $output; } My product is divided into gender and is written like Code: [Select] function cat_content_ladies($sel_cat, $sel_product, $female = true) { $output = "<ul class=\"regions\">"; $cat_set = get_all_cats($female); while ($cat = mysql_fetch_array($cat_set)) { if ($cat["id"] == $sel_cat['id']) { $product_set = get_products_for_female($cat["id"], $female); $output .= "<tr>"; while ($product = mysql_fetch_array($product_set)) { if ($cat["id"] == $sel_cat['id']) { $output .= "<tr>"; $output .= "<div class=\"pre\"><a href=\"product_detail.php?product=" . urlencode($product["id"]) . "\"></li>"; $output .= "<img src=\"{$product["img_src"]}\" height=\"121\" width=\"121\">"; $output .= "<div>{$product["prod_name"]}</a></div>"; } } $output .= "</tr>"; } } return $output; } My variation table is set up in thumb nails and is written in this function Code: [Select] function show_thumb($sel_product, $sel_var, $public = true) { $output = "<ul class=\"subjects\">"; $product_set = get_all_products($public); while ($product = mysql_fetch_array($product_set)) { $output .= "<li"; if ($product["id"] == $sel_product['id']) { $output .= " class=\"selected\""; } //$output .= "><a href=\"product_detail.php?product=" . urlencode($product["id"]) . //"\">{$product["id"]}</a></li>"; if ($product["id"] == $sel_product['id']) { $var_set = get_variations_for_product($product["id"], $public); $output .= "<ul class=\"pages\">"; while ($var = mysql_fetch_array($var_set)) { $output .= "<li"; if ($var["id"] == $sel_var['id']) { $output .= " class=\"selected\""; } $output .= "><a href=\"product_detail.php?var=" . urlencode($var["id"]) . "\">{$var["id"]}</a></li>"; } $output .= "</ul>"; } } $output .= "</ul>"; return $output; } any light on this subject would be greatly appreciated. I am having problems with my $_GET. When a user chooses an Article from "article_index.php", they click on a hyperlink, e.g. Code: [Select] <a href="<?php echo BASE_URL; ?>articles/postage-meters-can-save-you-money"> This triggers my Mod_Rewrite... Code: [Select] RewriteEngine on #PRETTY: articles/postage-meters-can-save-you-money #UGLY: article.php?slug=postage-meters-can-save-you-money RewriteRule articles/([a-zA-Z0-9_-]+)$ article.php?slug=$1 Which should take them to "article.php?slug=postage-meters-can-save-you-money" and then this code is supposed to grab the "slug" and retrieve the Article... Code: [Select] // Attempt to Retrieve Article. if (isset($_GET['slug'])){ // Slug found in URL. // Set Slug. $slug = $_GET['slug']; That part is working fine, however, if I go into the Address Bar and delete out the slug, so my URL looks like this... Code: [Select] www.MySite.com/articles/"> I would expect the ELSE part of the above code to kick in... Code: [Select] }else{ // Slug not found in URL. header("Location: " . BASE_URL . "index.php"); }//End of ATTEMPT TO RETRIEVE ARTICLE Unfortunately I am just getting this error... Quote Not Found The requested URL /articles/ was not found on this server. Apache/2.0.59 (Unix) PHP/5.2.6 DAV/2 Server at local.debbie Port 80 Why is my ELSE not detecting that there is no slug?? Debbie Hi I have written a simple bit of code, i used to code php a little and have just decided to start coding php again but for the life of me can't work out why this isn't working, so if someone could help this would be great. address www.mysite.co.uk/index.php?vid=video2 <php if (isset($_GET['vid'])){ $video=$_GET['vid']; }else{ $video="video1"; } when i echo $video i only get video=1 I am trying to do isset($_GET but I have a bizarre problem come up. I am using "id" as one of my fields but when I try to use it in the code it says it is not recognised. However I use this field quite widely. The code its coming up with is "Undefined variable: id" but I cant see why it has a problem with id. My code is: <?php if(isset($_GET['id'])){ $sql = mysql_query("SELECT * FROM productfeed WHERE id='$id' LIMIT 1"); } { while($row = mysql_fetch_array($sql)) $id = $row['id']; $image = $row['awImage']; $link = $row['link']; $description = $row['description']; $fulldescription = $row['fulldescription']; $price = $row['price']; echo "<div class=\"productdisplayshell\"> <div class=\"productdisplayoutline\"> <div class=\"productborder\"><center> <a href=\"$link\" target=\"_blank\" ><img src=\"$image\" /></a> </center> </div></div> <div class=\"productdescriptionoutline\"><div class=\"productdescriptionbox\"> <a href=\"$link\" target=\"_blank\" >$description</a> </div><div class=\"productfulldescriptionbox\"> $fulldescription </div></div> <div class=\"productpriceoutline\"> <div class=\"productpricebox\"><center>&#163; $price</center></div> <div class=\"productbuybutton\"><center><a href=\"$link\" target=\"_blank\" ><img src=/images/buybutton.png /></a></center></div></div></div>"; } ?> Im trying to use an if isset to stop my error messages displaying before they submit the form it worked on another part of my website but wont work for this, It just wond submit the form at all when i click submit here is the code: <html> <head> </head> <body> <form action="contact.php" method="post"> <fieldset> <legend>Contact Us</legend> Your Email:*<br> <input type="text" name="email"><br> Subject:*<br> <select name="subject"> <option value=""></option> <option value="1">Recruitment</option> <option value="2">Absense</option> <option value="3">Enquiry</option> </select> <br> Message:*<br> <textarea name="message" cols="50" rows="5"></textarea><br> <?php require_once('recaptchalib.php'); $publickey = "6LeB8LwSAAAAAKwvC3HWJNwWw9vYiSEkvFEvDduD"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> <br> <input type="submit" value="Send Email"> </form> Required fields are marked with a *<br><br> <?php if(isset($_POST['Submit'])){ $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $to = "nathan_k_boothby_1994@hotmail.co.uk"; //checcking that all relevent information is entered and correct if(!$message || !$email) { $errmessage ="Please fill in all required data."; } require_once('recaptchalib.php'); $privatekey = "6LeB8LwSAAAAAA_0IIEnAxL5uOau0TBm83Iog7Ey"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $errmessage ="The text you wrote did not match the image."; } //Sending the email if nothing is wrong if(!$errmessage) { header("location:send.php?to=".$to."&subject=".$subject."&email=".$email."&message=".$message.""); }else{ echo $errmessage; } } ?> </fieldset> <br><br><br> </body> </html> And here is a link to the page: http://valiantflight.comlu.com/emailer/contact.php Any help will be greatly appriciated, Thanks, Blink359 Hi there, I have just move hosts with our website and it loads the frontpage but non of the subsequent pages. The site works like this, depending on the variables in the address depends which page and which template are loaded into it. If the template is "ros" it loads rosettes template, if it is "tro" it loads trophy template, and then the name of the item, ie "hazel" will load up the hazel product page. All it is doing at the moment is loading the home.php page. The code to do this is below: <? if (!isset($template)) {include ("static/home.php");} else if (isset($id)) { if (!file_exists("site_templates/$template.php")) { echo "OOPS! <P> The template you have requested does not exist!<BR><BR><BR><BR><BR><BR>"; }elseif (file_exists("site_templates/$template.php")) { include ("site_templates/$template.php"); } } ?> It worked with our last host, but refuses to work now. Is there someone out there that can help. Thanks in advance, Phil The below should be making it so that in order for "customer reviews" to be visible, you should need the "&review" in the url, but it's coming up regardless if it's in the URL or not. http://ghosthuntersportal.com/store.php?product=2 Code: [Select] elseif(isset($_GET['product'])){ $product_id=$_GET['product']; $sql500="SELECT * FROM $tbl_name3 WHERE product_id='$product_id'"; $result500=mysql_query($sql500); $num_rows500=mysql_num_rows($result500); if($num_rows500==0){ $average_rating=0; } else{ while($row500=mysql_fetch_array($result500)){ extract($row500); $total = $total + $review_product_rating; $review.=' <div class="review_container"> <div>'.$review_product_rating.' '.$review_title.'</div> <div>By '.$review_name.' from '.$review_location.' on '.$review_date.'</div> <div>Pros: </div><div>'.$review_pros.'</div> <div>Cons: </div><div>'.$review_cons.'</div> <div>Describe Yourself: </div><div>'.$review_describe.'</div> <div>Best Use: </div><div>'.$review_best_use.'</div> <div>'.$review_text.'</div> </div> '; } $review_product_rating_total=$total; $average_rating=$review_product_rating_total/$num_rows500; } $sql50="SELECT * FROM $tbl_name WHERE product_id='$product_id'"; $result50=mysql_query($sql50); while($row50=mysql_fetch_array($result50)){ extract($row50); $section=ucwords($product_category); $product_name=ucwords($product_name); $crumbs='<a href="./index.php">Home</a> <span class="eleven">></span> <a href="./store.php?cat='.$product_category.'">'.$section.'</a> <span class="eleven">></span> <a href="./store.php?product='.$product_id.'">'.$product_name.'</a>'; $section=" - ".$section; $product_highlights=str_replace("[","<li>", $product_highlights); $product_highlights=str_replace("]","</li>", $product_highlights); $content.=' <div class="product_wrapper"> <div>'.$product_name.'</div> <div class="product_image"> <div><img src="'.$product_image.'" alt="'.$product_name.'" /></div> </div> <div class="product_details"> <div class="product_price">Price: $'.$product_price.'</div> <div class="product_code">GHP#: '.$product_code.'</div> <div class="rating_image">'; if($num_rows500==0){ $content.='No Rating'; } else{ $content.='<img src="'.$average_rating.'.png" alt="'.$average_rating.'" />'; } $content.=' <span class="twelve">('.$num_rows500.' Reviews)</span></div><div>'; if(isset($product_highlights)){ $content.='<div class="product_highlights_text">Product Highlights</div><div class="product_highlights_item"><ul>'.$product_highlights.'</ul></div>'; } else{ } $content.='</div> </div> </div> '; } $content.='<div class="product_links_headers">Overview | Specifications | Customer Reviews</div>'; if(isset($review)){ $content.='<div style="margin-top: 400px;">'.$review.'</div>'; } elseif(isset($specifications)){ $content.='<div style="margin-top: 400px;">'.$product_specifications.'</div>'; } else{ } } Code: [Select] if (isset($_COOKIE['hide_div']['0']) && isset($_COOKIE['hide_div']['2'])){ $cookie1 = $_COOKIE['hide_div']['0']; $cookie2 = $_COOKIE['hide_div']['2']; } if ($cookie1 == $cat_id OR $cookie2 == $cat_id) { foreach ($this->forums as $forum_id => $forum_data) { if ($forum_data['category'] == $cat_id) { //----------------------------------- // We store the HTML in a temp var so // we can make sure we have cats for // this forum, or hidden forums with a // cat will show the cat strip - we don't // want that, no - we don't. //----------------------------------- $temp_html .= $this->process_forum($forum_id, $forum_data); } } if ($temp_html != "") { $this->output .= $this->html->CatHeader_Expandedhidden($cat_data); $this->output .= $this->html->end_this_cat(); } unset($temp_html); }else{ $cookie1 = ''; $cookie2 = ''; why in the world is it displaying Undefined variable: cookie1 and cookie2 as errors? When I declared both of them even AFTER my if statement, this is bogus dude, lol this isset stuff is really confusing or am i just not doing it right? For some reason the !isset() function doesnt seem to work i cant find out why hope you guys will be able to help Here is the html code for the form where the user enters the data Code: [Select] <div id="contact_form"> <h2>On Site SEO Signup Form</h2> <form method="post" name="contact" action="http://www.techbreeze.in/freeseo.php"> <label for="uname">Name:</label> <input name="uname" type="text" class="required input_field" id="uname" /> <div class="cleaner h10"></div> <label for="email">Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" /> <div class="cleaner h10"></div> <label for="website">Website:</label> <input type="text" class="required input_field" id="website" name="website"/> <div class="cleaner h10"></div> <label for="ftp">Your FTP Login URL:</label> <input type="text" class="required input_field" id="url" name="url" /> <div class="cleaner h10"></div> <label for="username">Your FTP Username:</label> <input type="text" class="required input_field" id="user" name="user" /> <div class="cleaner h10"></div> <label for="password">Your FTP Password:</label> <input type="password" class="required input_field" id="pass" name="pass"/> <div class="cleaner h10"></div> <input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" /> <input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" /> </form> </div> And here is the code for the .php file where the !isset() function is used Code: [Select] <?php // validation expected data exists if( !isset($_POST['uname'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Name" field empty!'); } if( !isset($_POST['pass'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Password" field empty!'); } if( !isset($_POST['email'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Email" field empty!'); } if( !isset($_POST['website'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Website" field empty!'); } if( !isset($_POST['url'])) { die ('We are sorry, but all the fields are necessary you cant leave the "FTP URL" field empty!'); } if( !isset($_POST['user'])) { die ('We are sorry, but all the fields are necessary you cant leave the "Username" field empty!'); Thanks in advance Sorry for the miss spell on correctly counldn't edit the title
I need to have the following 3 varibles checked to see if they are set and if not display an error saying "All fields need to be filled in." My problem is that it's not working. Did I mess up on my if statement? $tempneeded $lowtemp $gallons <?php $tempneeded = $_POST['tempneeded']; $lowtemp = $_POST['lowtemp']; $gallons = $_POST['gallons']; htmlspecialchars($tempneeded, ENT_QUOTES, 'UTF-8') . ' ' . htmlspecialchars($lowtemp, ENT_QUOTES, 'UTF-8') . ' ' . htmlspecialchars($gallons, ENT_QUOTES, 'UTF-8') . ' ' . $wgd = .5; $tempdiff = $tempneeded - $lowtemp; $wattsneeded = $tempdiff * ($gallons * $wgd); if (!isset ($lowtemp,$tempneeded,$gallons)) { echo "<b>All fields need to be filled in.</b>"; } else { echo "<b>You will need a total of $wattsneeded watts to rasie your tempature $tempdiff degress, from $lowtemp to $tempneeded.</b></td></tr>"; } ?> Edited by msebar, 08 October 2014 - 01:43 PM. I've tried both of these methods, but neither are working. The if statement fails every time. Code: [Select] if(isset($_POST['submit'])){ Code: [Select] if(isset($submit)){ This is the form: Code: [Select] <form id="form1" name="form1" method="post" action="join.php"> <label><span> <input name="email" type="text" class="keywords" id="textfield" maxlength="50" value="Join my mailing list..." onclick="make_blank();" /> </span> <input name="submit" type="image" src="images/search.gif" class="button" onclick="return checkmail(this.form.email);"/> </label> </form> Hello! This may sound like a stupid question but i have been trying to get this working all day and its driving me crazy.
Ive been asked to take over development of this project, he sent me his code and its a little out of date so im trying to update it. Here is what i cant work out.
I have this little snippet of code:
if ($page == "showthread"){ showThread(); }There are several more like that, but you dont need a whole list. That code seems to be throwing up this error when i go to that specific page: Notice: Undefined index: error in ..... All well and good, i would usually do this: if (isset($page) == "showthread"){ showThread(); }Thats fine and dandy, the error goes away. But now, when i go to that page, it redirects me and gives me my error message for a non-existing page. Its really frustrating me. Can you help me fix this little error? I have a simple log in form. By debugging I found that isset post submit function is not responding. It remains on the same page after submitting form. I have googled all the possible solutions to this problem but none worked. Any help is greatly appreciated. The form is in multiplelogin.php file and the code is in multi.php file. After login redirection is to teachers.php file. <?php session_start(); $conn = mysqli_connect("localhost", "root", "", "signup");
if(isset($_SESSION['username'])) {
?>
<head> <link rel="stylesheet" type="text/css" href="bootstrap.css"> <title> Teachers Students Login </title> </head> <body class="bg-secondary"> <div class="container"> <div class="row justify-content-center"> <div class="col-log-5 bg-light mt-5 px-0"> <h3 class="text-center text-light bg-primary py-3 px-5"> Log In </h3>
<div class="form-group px-5"> <input type="email" name="email" class="form-control form-control-lg" placeholder="Email" required> </div> <div class="form-group px-5"> <input type="password" name="password" class="form-control form-control-lg" placeholder="Password" required> </div> <div class="form-group px-5"> <input type="submit" name="submit" value="Submit" class="btn btn-primary btn-block"> </div> </form> </div> </div> </div>
<?php
ini_set( 'display_errors', 1 );
$password = $_POST['password'];
$stmt = mysqli_stmt_init($conn); header("Location: multilogin.php?error=sqlerror"); exit();
} else { mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($pwdCheck == false) {
exit(); $_SESSION['username'] = $row['username']; $_SESSION['email'] = $row['email']; header("Location: teachers.php?login=success");
exit ();
exit();
exit();
else {
exit(); Hi there, I've been trying to implement pagination to an existing script that displays products, but at present only displays next and back buttons. The number of products is now increasing and we would like to show the number of pages of results but the tutorials I've been going through seem to use a very different way of displaying the results to the script we currently have. Does anyone have any suggestions how I could add pagination to this form..... // Build Pagination $ByPage = ($prod_rows * $prod_cols); $qnav = "SELECT devbg_products.*, devbg_categories.*, devbg_subcategories.* FROM devbg_products LEFT JOIN devbg_categories ON devbg_products.ItemCategory = devbg_categories.CategoryID LEFT JOIN devbg_subcategories ON devbg_products.ItemSubcategory = devbg_subcategories.SubcategoryID WHERE devbg_products.ItemCategory = " . sql($cgid); $rnav = mysql_query($qnav) or die(mysql_error()); $rows = mysql_num_rows($rnav); if($rows > $ByPage) { $pages = ceil ($rows / $ByPage); echo "<br>\n"; echo "<table align='center'>\n"; echo "<tr>\n"; echo "<td align=center><font face=verdana size=2>"; echo "<form method='POST' action='ShowCategory.php'>\n"; echo "<input type='hidden' name='Start' value='" . ($Start - $ByPage) . "'>\n"; echo "<input type='hidden' name='CategoryID' value='" . $_REQUEST["CategoryID"] . "'>\n"; echo "<input type='hidden' name='SubcategoryID' value='" . $_REQUEST["SubcategoryID"] . "'>\n"; if (($Start - $ByPage) <> -$ByPage) { echo "<input class='sub' type='submit' value='<<< Back' name='btnBack'>\n"; echo "</form>\n"; echo "</td>\n"; } echo "<td>\n"; echo "<form method='POST' action='ShowCategory.php'>\n"; echo "<input type='hidden' name='Start' value='" . ($Start + $ByPage) . "'>\n"; echo "<input type='hidden' name='CategoryID' value='" . $_REQUEST["CategoryID"] . "'>\n"; echo "<input type='hidden' name='SubcategoryID' value='" . $_REQUEST["SubcategoryID"] . "'>\n"; if ($Start + $ByPage < $pages * $ByPage) { echo "<input class='sub' type='submit' value='Next >>>' name='btnNext'>"; } echo "</form>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table><br><br>\n"; } I run into this every now and again and wonder if someone knows what I could be doing wrong. Using a simple $ClientID = $_GET['ID']; is not working on a certain page, I can see the ID=193 value in the address field but $ClientID remains an empty variable. I even try $_REQUEST instead, still nothing. I'm puzzled. Hello, I am working on a cms site but I am having trouble with retrieving some info by id. I followed a tutorial on youtube and my code looks correct but my ID string is empty. Any help would be greatly appreciated. Class with functions
class Article {
$query= $pdo->prepare("SELECT * FROM article"); ************************************* Call to functions
include_once('includes/connection.php'); $article = new Article;
var_dump($_GET, $_POST);
if (isset($_GET['id'])){
print_r($data); When I var_dump the get and post I get array(0) { } array(0) { }. fetch all works great but fetch data does not and I am not sure where the post id is pulling from since there isn't a prior connection. Thank You, Devin I am attempting to insert data into a db via '?' in the url. The demonstration I've seen appears to work fine.
I am using Wamp 2.2, Apache 2.2.22, PHP 5.4.3 and MySQL 5.5.24.
My efforts merely take me off on a standard search.
Has the global $_GET changed.
My code.
<?php //error_reporting(0); require 'db/connect.php'; echo 'Connected'; //Added to be sure to be sure connected if(isset($_GET['first_name'])) { $first_name = trim($_GET['first_name']); if($insert = $db->query(" INSERT INTO people(first_name, last_name, bio, created) VALUES ('{$first_name}', 'Garrett', 'I\'m a web developer', NOW()) ")) { echo $db->affected_rows; } } ?> After the file is initiated the idea is to enter into the url ?first_name=Whatever press enter, the file should run and at the same time update the db. What am I missing. kev Okay im trying to make it so when some is on this link ("?serv=del&id=$ID") it displays a portlet of a yes/no form. onces yes/no is picked it goes to ("?serv=del&id=$ID&del=true"). I have no idea if im doing this right or if theres a better way of doing it. But trying to fix this problem has almost made me throw my computer threw my window. Thanks in advanced. <?php if(isset($_GET['serv']) && $_GET['id'] == $serverid && $_GET['del'] == 'true') { if($_POST['ture']) { mysql_query("DELETE FROM `notifications` WHERE `id`='$msgid'"); Echo "<center>Message Deleted</center>"; } else { Echo "<center>Message delete request has been canceled.</center>"; } } elseif(isset($_GET['serv']) && $_GET['id'] == $serverid) { ?> <div class="usercp_body"><!-- UserCP Notification Manage Start --> <div id="dash_chart" class="portlet" style="width:100%;margin: 0 auto;"> <div class="portlet-header"> <h4><center>All Servers For <?php echo $username; ?></center></h4> </div> <div class="portlet-content"> <form action="manage.php?serv=del&id=<?php echo $serverid; ?>&del=true" method="post"> <input type="submit" class="bgbtn blue" value="Yes" name="true" /> <input type="submit" class="bgbtn blue" value="No" name="false" /> </form> </div> </div> </div> <?php } ?> Okay I have index.php in which i used <?php echo $_GET['name']; ?> and its working fine all over the page except a wizard form that loads on a button click. <?php echo $_GET['name']; ?> is working on entire page text (wherever i have used this) except a wizard form which loads on a button click. All the files of that wizard form are located in my website folder (e.g. wizard.php, wizard.js & wizard.css). here's how wizard.php code starts: <div class="wizard-container"> <div class="card wizard-card" data-color="green" id="wizardProfile"> <form action=""> <div class="wizard-header"> <h3 class="wizard-title"> GENERATE A FRESH <?php echo $_GET['name']; ?> CODE </h3> <h5 style="margin-left: 10px; margin-right: 10px;">Our interactive generator will guide your through the process</h5> </div> i want that <?php echo $_GET['name']; ?> should also work in wizard form but it shows the following error: C:\xampp\htdocs\NameGenerator\content\hbox\html\wizard.php on line 7 Sorry for my bad explanation i don't know much about php so i explained it like this Please help... |