Jump to content

Valentina

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Valentina's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well, I discovered what I was doing wrong... I wasn't registering the arrays in the form. I was writing the code wrong. Anyway, I got that fixed, but this SESSION method doesn't work for what my script is trying to do... My form has multiple search options... lots of checkboxes and text boxes... When I use SESSION, it works to do a search for the first time (I don't even know if the pagination works) but if I want to do another search, choosing different boxes to check, the script obviously remembers the first choices too. I am not sure what I should do.... Valentina
  2. Well, these variables are coming from a form that uses method POST. As I said, I tried SESSION (I posted the code earlier) but I am not sure if I'm doing something wrong and I have no idea what I'm supposed to do next with those variables, to pass them to the next page. Valentina
  3. vicodin, I am not sure I understand what you're saying.... I tried using POST like this: $hybridizer = htmlentities($_POST['hybridizer']); $cleanhybridizer = trim($hybridizer); $seedparent = htmlentities($_POST['seedparent']); $cleanseedparent = trim($seedparent); $color = $_POST["color"]; $color_1 = $color[0]; $color_2 = $color[1]; $color_3 = $color[2]; $color_4 = $color[3]; $color_5 = $color[4]; $color_6 = $color[5]; $color_7 = $color[6]; $color_8 = $color[7]; $color_9 = $color[8]; $flowerform = $_POST["flowerform"]; $flowerform_1 = $flowerform[0]; $flowerform_2 = $flowerform[1]; $flowerform_3 = $flowerform[2]; $orgcountry = htmlentities($_POST['orgcountry']) ; $cleanorgcountry = trim($orgcountry); $year = htmlentities($_POST['year']) ; $cleanyear = trim($year); And then later, for pages, I have this: echo "<a href='{$_SERVER['PHP_SELF']}?page_number=$next&hybridizer=$hybridizer&seedparent=$seedparent&color[] .......... all the rest of them ........ </a> When you click on the next page, there are no variables. They are lost. I tried doing all these using GET in the form. It works, but it doesn't carry all the variables. Valentina
  4. Lisa, I have no idea how to do that. If you could offer some code to help me, I would appreciate it very much. vicodin, I am trying to create links for pages. I want to query the MySql database, get a bunch of results and display only 10 per page. I have no problem doing all these using GET, but it's not working with POST. I need to use POST. This is my code when trying with SESSION: <?php session_start(); ?> <html> <head> ...... stuff here, form....... if (!isset($_SESSION['hybridizer']) || !isset($_SESSION['seedparent']) || !isset($_SESSION['color[]']) || !isset($_SESSION['flowerform[]']) || !isset($_SESSION['orgcountry']) || !isset($_SESSION['year'])) { $_SESSION['hybridizer']=$_POST['hybridizer']; $_SESSION['seedparent']=$_POST['seedparent']; $_SESSION['color[]']=$_POST['color[]']; $_SESSION['flowerform[]']=$_POST['flowerform[]']; $_SESSION['orgcountry']=$_POST['orgcountry']; $_SESSION['year']=$_POST['year']; } $hybridizer = htmlentities($_SESSION['hybridizer']); $cleanhybridizer = trim($hybridizer); $seedparent = htmlentities($_SESSION['seedparent']); $cleanseedparent = trim($seedparent); $color = $_SESSION['color[]']; $color_1 = $color[0]; $color_2 = $color[1]; $color_3 = $color[2]; $color_4 = $color[3]; $color_5 = $color[4]; $color_6 = $color[5]; $color_7 = $color[6]; $color_8 = $color[7]; $color_9 = $color[8]; $flowerform = $_SESSION['flowerform[]']; $flowerform_1 = $flowerform[0]; $flowerform_2 = $flowerform[1]; $flowerform_3 = $flowerform[2]; $orgcountry = htmlentities($_SESSION['orgcountry']); $cleanorgcountry = trim($orgcountry); $year = htmlentities($_SESSION['year']); $cleanyear = trim($year); ........ then all the script stuff..... Am I doing something wrong here? How exactly am I supposed to write the links to the next page? Would it be something similar to writing them for GET, but just use SESSION[] instead? Or there is no need to write everything in the link anymore... I am really not sure what I'm doing... I appreciate your help! Valentina
  5. Hello, I believe this question was probably answered to death, and I looked for old posts, but I couldn't find anything to solve my problem... Could somebody please help me? I wrote a search script that needs pagination. The script uses the _POST method to deal with the variables in the form. Being a beginner, it took me a while to realize that _POST does not carry the variables to the next page, but I cannot use _GET - there are too many variables that need to be passed to the next page. I tried SESSION also, but I either don't use it right, or it's simply not working... I cannot tell. What would be the best way to deal with this problem? I can post parts of the script if you need me to, I just am not sure what exactly would be needed... Thank you so much for your help! Valentina
  6. I just want to say "Thank you" again, for all your help. My script works now... I finally discovered what I was doing wrong. Probably most of you already know this, but maybe it's useful for beginners like me, so I will explain: I was using the "heredoc syntax" to write in my newfile.php and I didn't know that this syntax is escaping the "$" sign. The tutorial I read (where I found out about this syntax) did not give me this information I finally got smart and opened the newfile.php to see what am I writing in there... Thank you, everybody! I appreciate it. Valentina
  7. I am trying to generate a new file (newfile.php), from the search file, that will show more details about a certain row in the database. And I need this file to be generated new, clean, for every item/row. If you go to the link I gave earlier you will have a better idea about what I am trying to do... Yes. I changed the while loop into a for loop and it works, but I get exactly the same results (as for the while loop). The loop is not the problem. I get the error when I try to implement the Mysql results into the newfile.php. Thank you for your help! Valentina
  8. Well... I guess I need more brain I tried the code and I get an error message... the "CONDITIONS" are not imported in the new file. Everything works great until it generates the new file... I am sure I am doing something wrong... Could you please take another look at this? Here's the page where I am trying this: http://www.valentinac.com/test stuff/search5.php You can only search for "America", "Lipstick", "Ecuador Pink"... it's just a small database for trying the script. And this is my code: <?php mysql_connect(...etc...) or die(mysql_error()); mysql_select_db("...database...") or die(mysql_error()); $query = "SELECT * FROM Brugmansia WHERE Cultivar LIKE \"%$cleanx%\" OR PodParent LIKE \"%$cleanx%\" or PollenParent LIKE \"%$cleanx%\" ORDER by Cultivar"; $result = mysql_query($query) or die("Couldn't execute query"); echo "<table border=\"1\">"; echo "<tr><th>Cultivar</th>"; echo "<th>Pod Parent</th>"; echo "<th>Pollen Parent</th>"; ...etc while ($row= mysql_fetch_array($result)) { $myFile = "newfile.php"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = <<<ABC <html> <head> <title> </title> </head> <body> <?php //.....() $result = mysql_query("SELECT * FROM Brugmansia where CONDITION='{$_GET['CONDITION']}'"); $row = mysql_fetch_array($result) echo "<p>This is a page for " . $row['Cultivar'] . "<br>"; } ?> <p>something else here...</p> </body> </html> ABC; fwrite($fh, $stringData); fclose($fh); echo "<tr>"; echo "<td>"; echo "<b><a href=\"newfile.php?CONDITION={$row['Cultivar']}\" target=\"_blank\">" . $row['Cultivar'] . "</a>" . "</b></td>"; echo "<td>" . $row['PodParent'] . "</td>"; echo "<td>" . $row['PollenParent'] . "</td>"; ....etc..... echo "</tr>"; } echo "</table>"; ?> All this works only if I don't generate the new file. And even when I do, it works as long as I don't use the databse variables in the code. What am I doing wrong? Thank you for your help! Valentina
  9. Wow! That was fast. Thank you SO much!! Valentina
  10. I will start by saying that I am a beginner in PHP, and when I say beginner I mean "dummy" actually. I read a tutorial online and now I have dreams of writing php scripts.... Anyway, I am trying to create a search function for a database, using MySql. I managed to do that but in the table that displays the results I want to have the items in the first column linked to a new page that opens on click (to show more details about the respective item, in the new page). My problem is that I don't know how to import the MySql array into the new page created. Could somebody help me, please? Thank you very much! Valentina
×
×
  • 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.