Jump to content

gospabode2

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Everything posted by gospabode2

  1. Whoops Sorry, Teynon, Guess I got a little overexcited! Now I know why trashcat is not amused.
  2. The Code you just posted seemed to be working when I tested it. Do you still have an issue and if so, what? [attachment deleted by admin]
  3. Thank you SO Much. I must have been getting that error because as I was deleting those quotes, I was adding something else on accident or something of that sort of thing. I have been known to not notice typos. Sorry I was such a pain. Thanks for the advice for future posting. I hope that if I have errors in the future, I can explain them better so you don't have to ask for more information.
  4. Thanks for the advice. I had already echoed out all of the information, everything with POST is working. And I had already tried with and without those single quotes and when I had single quotes I did not get an error message, but when I didn't have them I did get an error message. Right now, I am not at my work computer, so I cannot retry and try to get the same error message, but I really have tried to debug. I have echoed out everything I possibly could. Everything seems to be working except the most important thing: the ordering. When I am at work tomorrow, I will retry removing those quotes, maybe the error message was for something else, but I am pretty sure I already tried that. Thanks for helping out. I really try not to be a pain to all of you, but you guys, all people who have helped me thus far, have been an immeasurable help. I will retry at work tomorrow. Thanks!
  5. Wouldn't the Div automatically expand to fit the contents within if it does not have a fixed width and height?
  6. Well we still need to see the code you are having an issue with so that we can figure out what you changed.
  7. Okay I see what you are saying. Thanks a lot. I haven't worked with sessions much yet, so that is still new to me. The problem that I originally had still seems to be there: It doesn't reorder the results. I really can't figure out why. Any help would be appreciated! Here is updated code: <?php session_start(); mysql_connect("") or die (mysql_error()); mysql_select_db("") or die (mysql_error()); if(isset($_POST["order"])) { $order = mysql_real_escape_string($_POST["order"]); $_SESSION['order'] = $order; } elseif(isset($_SESSION['order'])) { $order = $_SESSION['order']; } else{ $order = "IDa"; } $sql = mysql_query("SELECT * FROM orphans ORDER BY '$order'") or die (mysql_error()); // This line sets the "LIMIT" range $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; //Pagination Stuff // $sql2 is what we will use to fuel our while loop statement below $sql2 = mysql_query("SELECT * FROM orphans ORDER BY '$order' $limit") or die(mysql_error()); //Pagination Stuff $outputList = ''; while($row = mysql_fetch_array($sql2)){ $ida = $row['IDa']; $firstname = $row['FirstName']; $lastname = $row['LastName']; $birthdate = $row['BirthDate']; $gender = $row['Gender']; $sponsorcount = $row['SponsorCount']; $createdon = $row['Created_On']; $changedon = $row['Changed_On']; $active = $row['active']; $picone = $row['PictureOne']; $outputList .= '<div class="child"><div class="picbox"><div class="imgchild"><a href="/abode/childbio.php?id=' . $ida . '?iframe=true&width=780&height=600" rel="prettyPhoto"><img title="' . $firstname . ' ' . $lastname . '" style="display: block; margin: 0 auto;" alt=" No Photo Available" class="picture" src="/orphans/pic1/'. $picone . '" /></a></div></div>' . '<div class="descrip"><a href="/abode/childbio.php?id='.$ida.'?iframe=true&width=780&height=600" rel="prettyPhoto"><b>'.$firstname.' '.$lastname.'</b></a><br />' . 'Age: <b>' . birthday ("$birthdate.") .'</b><br />' . 'Birthday: <b>' . $birthdate . '</b><br /> ' . 'Gender: <b>' . $gender . '</b><br />' . '</div></div>'; } // close while loop ?> <div class="pagdisplay"> <?php echo $paginationDisplay; ?> <form method="post" action="/abode/children.php"> Sort Orphans <select name="order"> <option value="LastName ASC">A-Z</option> <option value="Gender DESC">Boys First</option> <option value="Gender ASC">Girls First</option> <option value="BirthDate ASC">Youngest First</option> <option value="BirthDate DESC">Oldest First</option> </select> <input type="submit"> </form> <div class="totalorphs">Total Orphans:<?php echo $order;?></div> </div> <div style="width: 100%;" class="children"> <?php print "$outputList"; ?> </div>
  8. Hello, I am trying to get my database to show a drop down menu where the user can choose an option to order the results. I have made the drop down menu and have set it up to post to itself and receive it, and I know that when I submit it is getting the result posted, because of experiments I have done with echo, so I am out of options. No matter what, I cannot make the last ordered differently through Mysql. It just remains the same ordering as when I first visit the page. I am using adam's pagination to paginate. Here is my code, in a nutshell: PHP Up top: <?php mysql_connect("") or die (mysql_error()); mysql_select_db("") or die (mysql_error()); $order=$_POST["order"]; if(isset($_POST["order"]) and strlen($order)>0){ $order=$_POST["order"]; } else{ $order="IDa"; } ////////////// QUERY THE MEMBER DATA INITIALLY LIKE YOU NORMALLY WOULD $sql = mysql_query("SELECT * FROM orphans ORDER BY '$order'") or die (mysql_error()); //////////////////////////////////// Adam's Pagination Logic //////////////////////////////////////////////////////////////////////// $nr = mysql_num_rows($sql); // Get total of Num rows from the database query if (isset($_GET['pn'])) { // Get pn from URL vars if it is present $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); // filter everything but numbers for security(new) //$pn = ereg_replace("[^0-9]", "", $_GET['pn']); // filter everything but numbers for security(deprecated) } else { // If the pn URL variable is not present force it to be value of page number 1 $pn = 1; } //This is where we set how many database items to show on each page $itemsPerPage = 10; // Get the value of the last page in the pagination result set $lastPage = ceil($nr / $itemsPerPage); // Be sure URL variable $pn(page number) is no lower than page 1 and no higher than $lastpage if ($pn < 1) { // If it is less than 1 $pn = 1; // force if to be 1 } else if ($pn > $lastPage) { // if it is greater than $lastpage $pn = $lastPage; // force it to be $lastpage's value } // This creates the numbers to click in between the next and back buttons // This section is explained well in the video that accompanies this script $centerPages = ""; $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 orphans ORDER BY '$order' $limit") or die(mysql_error()); //////////////////////////////// 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 ot 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. ' '; // 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 /////////////////////////////////////////////////////////////////////////// // Build the Output Section Here //Calculate Age in Years function birthday ($birthdate) { list($year,$month,$day) = explode("-",$birthdate); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($month_diff < 0) $year_diff--; elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--; return $year_diff; } $outputList = ''; while($row = mysql_fetch_array($sql2)){ $ida = $row['IDa']; $firstname = $row['FirstName']; $lastname = $row['LastName']; $birthdate = $row['BirthDate']; $gender = $row['Gender']; $sponsorcount = $row['SponsorCount']; $createdon = $row['Created_On']; $changedon = $row['Changed_On']; $active = $row['active']; $picone = $row['PictureOne']; $outputList .= '<div class="child"><div class="picbox"><div class="imgchild"><a href="/abode/childbio.php?id=' . $ida . '?iframe=true&width=780&height=600" rel="prettyPhoto"><img title="' . $firstname . ' ' . $lastname . '" style="display: block; margin: 0 auto;" alt=" No Photo Available" class="picture" src="/orphans/pic1/'. $picone . '" /></a></div></div>' . '<div class="descrip"><a href="/abode/childbio.php?id='.$ida.'?iframe=true&width=780&height=600" rel="prettyPhoto"><b>'.$firstname.' '.$lastname.'</b></a><br />' . 'Age: <b>' . birthday ("$birthdate.") .'</b><br />' . 'Birthday: <b>' . $birthdate . '</b><br /> ' . 'Gender: <b>' . $gender . '</b><br />' . '</div></div>'; } // close while loop ?> Html <div class="contentheader"></div> <p class="textheader">The Children</p> <div class="pagdisplay"> <?php echo $paginationDisplay; ?> <form method="post" action="/abode/children.php"> Sort Orphans <select name="order"> <option value="LastName ASC">A-Z</option> <option value="Gender DESC">Boys First</option> <option value="Gender ASC">Girls First</option> <option value="BirthDate ASC">Youngest First</option> <option value="BirthDate DESC">Oldest First</option> </select> <input type="submit"> </form> <div class="totalorphs">Total Orphans:<?php echo $order;?></div> </div> <div style="width: 100%;" class="children"> <?php print "$outputList"; ?> </div> Any Help would be greatly appreciated. Thanks! ** Edited to Fix Stupid Mistake
  9. Thanks Solved My Issue. I could have sworn I typed thos in last night. I remember thinking about it. Oh well, All's well that ends well. Sorry it was such an easy fix, hope you didn't waste time on it.
  10. Hello, I am still new to PHP, but am getting better. The Problem is, I have read all the tutorials and everything and successfully accomplished this at other places so I don't know what the issue is. I bet it is small, as it always seems to be an oversight that causes issues. I am trying to do a MySQL Update Query with variables and I keep getting this error message: Here is the code: mysql_query("UPDATE orphans SET FirstName = '$firstname' LastName = '$lastname' BirthDate = '$birthdate' Gender = '$gender' Description = '$decrip' SponsorCount = '$sponsorcount' Created_On = 'createdon' Changed_On = '$changedon' PictureOne = 'pictureone' PictureTwo = 'picturetwo' PictureThree = '$picturethree' PictureFour = $picturefour' PictureFive = '$picturefive' WHERE IDa = '$IDa'") or die(mysql_error()); The variables seem to be working, I just don't know what the issue is. Thanks for the help in advance! Edited to Fix Stupid Mistakes
  11. The Extra Quotes was IT! I was looking all over for something like that, but after a while of looking at your own code, everything lookes fine. I had the </table> inside of the document, I just didn't show it because it wasn't the PHP code I was worried about, but great eyes! You have been a tremendous help.
  12. Thanks DavidAM, That fixed a whole lot of issues, although I still have a couple of questions, if you don't mind. I copied the below method of printing it out from another tutorial, and was wondering if there is an issue with this code specifically, because when I insert it, everything goes white, but when I replace it with: $outputtable .= "hello"; Everything works great. Here is the code, I am wondering about: $outputtable = '<tr>' . '<td>ID#: </td>' . '<td><input type="text" name="IDa" value="' . $idas . '" readonly="readonly"/></td>' . '</tr>' . '''<tr>' . '<td>First Name: </td>' . '<td><input type="text" name="FirstName" value="' . $firstname . '" /></td>' . '</tr>' . '<tr>' . '<td>Last Name: </td>' . '<td><input type="text" name="LastName" value="' . $lastname . '" /></td>' . '</tr>' . '<tr>' . '<td>Birth Date: </td>' . '<td><input type="text" name="BirthDate" value="' . $birthdate . '" /></td>' . '</tr>' . '<tr>' . '<td>Gender: </td>' . '<td><input type="text" name="Gender" value="' . $gender . '" /></td>' . '</tr>' . '<tr>' . '<td>Sponsor Count: </td>' . '<td><input type="text" name="SponsorCount" value="' . $sponsorcount . '" /></td>' . '</tr>' . '<tr>' . '<td>Created On: </td>' . '<td><div id="calendarDiv"></div><input type="text" name="Created_On" readonly="readonly" value="' . $createdon . '" /></td>' . '</tr>' . '<tr>' . '<td>Updated On: </td>' . '<td><div id="calendarDiv"></div><input type="text" name="Changed_On" class="calendarSelectDate" value="' . $changedon . '"/></td>' . '<tr>' . '<td>Description: </td>' . '<td><textarea name="Description" cols="25" rows="10"value="' . $descrip . '"></textarea></td>' . '</tr>' . '<tr>' . '<td>Picture #1: </td>' . '<td><input type="text" name="PictureOne" value="' . $pictureone . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #2: </td>' . '<td><input type="text" name="PictureTwo" value="' . $picturetwo . '" /></td>' . '</tr>' . '<tr>' . '<td>Picture #3: </td>' . '<td><input type="text" name="PictureFour" value="' . $picturethree . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #4: </td>' . '<td><input type="text" name="PictureFour" value="' . $picturefour . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #5: </td>' . '<td><input type="text" name="PictureFive" value="' . $picturefive . '"/></td>' . '</tr>' . '<tr>' . '<td><input type="submit" />';
  13. Hello, I am new to PHP and am trying to build a couple of webpages that when the first is submitted, posts to the next webpages, and the PHP recieves it, then accesses the database according to the posted variables and displays the information in a form. I have gotten this to work on other pages, so I don't see what the issue is. I am not getting any results on the next page. Only a white screen. I think there must be some error in the semantics somewhere, but I, for the life of me, cannot figure it out. Please Help! In essence, here's what it is: First Page: <form action="editchild2.php" method="post"> <input type="checkbox" name="checkbox[]" value="' . $row['IDa'] . '"/> <input type="submit" value="Update Child" /> Receiving Page: <?php mysql_connect("database","table","password") or die(mysql_error()); mysql_select_db("table") or die(mysql_error()); $IDa = $_POST['checkbox']; $result = mysql_query("SELECT * FROM orphans WHERE IDa='$IDA'") or die(mysql_error()); mysql_fetch_array($result) or die(mysql_error()); $outputtable = ''; while($row = mysql_fetch_array($result)){ $idas = $row['IDa']; $firstname = $row['FirstName']; $lastname = $row['LastName']; $birthdate = $row['Birthdate']; $gender = $row['Gender']; $sponsorcount = $row['SponsorCount']; $createdon = $row['Created_On']; $changedon = $row['Changed_On']; $descip = $row['Despcription']; $pictureone = $row['PictureOne']; $picturetwo = $row['PictureTwo']; $picturethree = $row['PictureThree']; $picturefour = $row['PictureFour']; $picturefive = $row['PictureFive']; $outputtable .= '<tr>' . '<td>ID#: </td>' . '<td><input type="text" name="IDa" value="' . $idas . '" readonly="readonly"/></td>' . '</tr>' . '''<tr>' . '<td>First Name: </td>' . '<td><input type="text" name="FirstName" value="' . $firstname . '" /></td>' . '</tr>' . '<tr>' . '<td>Last Name: </td>' . '<td><input type="text" name="LastName" value="' . $lastname . '" /></td>' . '</tr>' . '<tr>' . '<td>Birth Date: </td>' . '<td><input type="text" name="BirthDate" value="' . $birthdate . '" /></td>' . '</tr>' . '<tr>' . '<td>Gender: </td>' . '<td><input type="text" name="Gender" value="' . $gender . '" /></td>' . '</tr>' . '<tr>' . '<td>Sponsor Count: </td>' . '<td><input type="text" name="SponsorCount" value="' . $sponsorcount . '" /></td>' . '</tr>' . '<tr>' . '<td>Created On: </td>' . '<td><div id="calendarDiv"></div><input type="text" name="Created_On" readonly="readonly" value="' . $createdon . '" /></td>' . '</tr>' . '<tr>' . '<td>Updated On: </td>' . '<td><div id="calendarDiv"></div><input type="text" name="Changed_On" class="calendarSelectDate" value="' . $changedon . '"/></td>' . '<tr>' . '<td>Description: </td>' . '<td><textarea name="Description" cols="25" rows="10"value="' . $descrip . '"></textarea></td>' . '</tr>' . '<tr>' . '<td>Picture #1: </td>' . '<td><input type="text" name="PictureOne" value="' . $pictureone . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #2: </td>' . '<td><input type="text" name="PictureTwo" value="' . $picturetwo . '" /></td>' . '</tr>' . '<tr>' . '<td>Picture #3: </td>' . '<td><input type="text" name="PictureFour" value="' . $picturethree . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #4: </td>' . '<td><input type="text" name="PictureFour" value="' . $picturefour . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #5: </td>' . '<td><input type="text" name="PictureFive" value="' . $picturefive . '"/></td>' . '</tr>' . '<tr>' . '<td><input type="submit" />'; } ?> <!Doctype html> <html> <head> <!--Stylesheets and Stuff--> </head> <body> <!--Divs and Paragraphs--> <form action="updatechild.php" method="post"> <table border="0"> <?php print "$outputtable"; ?> </table> </form> <!--/Divs and Paragraphs--> </body> </html> Whoops: Edited to Fix Stupid Mistakes.
×
×
  • 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.