Jump to content

berilac

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by berilac

  1. tried it and it works but it doesnt reset the session variable i dont think, as when you click refresh, it shows the error check messages...
  2. thank you to both of you. Like i said, i am extremely new to php and basically used some tutorials to help build a kind of test website. I then alter the code as much as i can to make it work for me as well as learn to understand it... i will try to implement a session varaible instead. Sounds a much better option, one i hadnt explored as i was using the knowledge id gained thus far...
  3. Hi, I have an html form included in a php file. when it submits it uses post to change a variable from 0 to 1, so that if any errors occur it will display relevant error messages. To briefly explain, when its set to 0, only the form is shown and no error checks are made, but when they click submit it changes it to 1 and allows the php to make error checks. (Sorry if this is badly explained - im new to php) however, on clicking refresh, i would like the variable to be reset to 0 so that no error checks are made, but i cant change the $_POST value back to 0. Heres the beginning to the code, which hopefully will clarify where ive made a complete idiot of myself with my bad coding... :| [code] <? /* Load html backplate */ include ("../html/head.html"); include 'db.php'; /* Check that the user has submitted their details */ $submitcheck = 0; $submitcheck = $_POST['submitcheck']; if ($submitcheck == 0) {   /* load form */   include ("../html/regfrm.html"); } else { $_POST['submitcheck'] = 0;   // Define post fields into simple variables   $first_name = $_POST['first_name'];   $last_name = $_POST['last_name'];   $email_address = $_POST['email_address'];   $username = $_POST['username'];   $website = $_POST['website'];   $info = $_POST['info']; [/code] Please, if anyone can help, it would be amazing. Just ask if i need to explain myself better, etc. Thank you Michael
  4. thank you, but does that mean for all iterations of $page in the code is should use $_GET? (with or without isset)...? im slightly confused, sorry. i know this is fairly simple. i just changed the if empty($page) statement to use !isset instead and got this error...im sure im just being simple. Error 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 '-2, 2' at line 1 Cheers
  5. if you wish to view the code as wole, it is as follows: it currently echo's to page number before the first image and as you will see, it never alters from one... [code] <? /* Load html backplate */ include ("../html/head.html"); // Get database connection include 'db.php'; /* set number of results per page */ $limit = 2; /* set query to retrieve images held in gallery */ $query_count = "SELECT * FROM gallery"; /* actually retrieve images held in gallery */ $result_count = mysql_query($query_count); /* count number of images */ $totalrows = mysql_num_rows($result_count); /* BEGIN ADDING IMAGES */ if (empty($page)) /* check if $page variable is empty */ {   $page = 1; /* if empty, set to page 1 */ } echo $page; $limitvalue = $page * $limit - ($limit);  /* set first image to pull for the current page */ $query = "SELECT * FROM gallery LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error " . mysql_error()); // selects all necessary data from gallery // shows error if one occurs /* Tip: The MySQL LIMIT value syntax is as follows:    LIMIT $row_to_start_at, $how_many_rows_to_return  */ if (mysql_num_rows($result) == 0) {   echo "There are no images in the Gallery"; } echo "<table>"; //start a table /* The following WHILE returns a row of data to the $row array. Each time the loop restarts, the next row of data is used. So, each pass of the loop returns a different row of data. */ while ($row = mysql_fetch_array($result)) {   echo ("<tr>\n<td>");   echo ("<img src=\"../" . $row["thumb_path"] . "\" alt=\"\">");   echo "</td>\n<td>";   echo ($row["title"]);   echo "</td>\n</tr>"; } echo "</table>"; /* add PREVIOUS link */ if ($page != 1) {   $pageprev = $page--;   echo ("<a href=\"php/browse.php?page=$pageprev\">PREVIOUS" . $limit . "</a> "); } else {   echo ("PREVIOUS "); //if first page, PREVIOUS is not a link } /* display PAGE NUMBERS */ $numofpages = $totalrows / $limit; for ($i = 1; $i <= $numofpages; $i++) {   if ($i == $page)   {     echo ($i . " ");   }   else   {     echo ("<a href=\"php/browse.php?page=$i\">$i</a> ");   } } if (($totalrows % $limit) != 0) //% function returns a remainder {   if ($i == $page)   {     echo ($i . " ");   }   else   {     echo ("<a href=\"php/browse.php?page=$i\">$i</a> ");   } } /* add NEXT link */ if (($totalrows - ($limit * $page)) > 0) //check if more pages are remaining {   $pagenext = ($page + 1);   echo("<a href=\"php/browse.php?page=$pagenext\">NEXT " . $limit . "</a>"); } else {   echo ("NEXT"); //if last page NEXT is not a link } mysql_free_result($result); /* clears $result just in case */ /* close html neatly */ include ("../html/foot.html"); ?> [/code]
  6. Hi everyone. You should be able to view the problem here: http://purpleart.110mb.com/php/browse.php Im just setting up a faux website for a bit of learning so you can basically ignore the content... This is the would-be gallery page(s). Ive got it so that page 1 now works and displays the correct images. However, when you click '2' or 'next', which passes "page=2" through the address bar the code does not respond accordingly. This checks to see if page is null and sets as one if so, but should leave it as 2, etc if stated in the address bar... if (empty($page)) /* check if $page variable is empty */ {   $page = 1; /* if empty, set to page 1 */ } but no matter what, it seems $page always=1 Sorry for the slight garbledness...(if that is a word), but if anyone could help I would be most grateful! Thank you, Michael
×
×
  • 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.