0

What im trying to do is this. I have created a fact repository frame which holds facts for the use to look for. The user looks for facts through a search text field in which they submit.

The search variable brings up on the page anything which matches the search to a title or description in my database.

If the search matches, it echos all the data from that factid on the screen. What i want to do is grab the $factid and pass it to the next page.

The $pathid is a problem too. The while loop in the code brings back results from query. This query is supposed to bring up the last record or pathid from a table in a database.

I want to pass both the $factid and $pathid variable to another page so i could insert both values in another table.

Does that make more sense? Sorry im not good at wording.


This is my first page, in which the user submits a search.

Help with Code Tags
PHP Syntax (Toggle Plain Text)

<form method="post" action="firstfact.php">
<input type="text" name="search">
<input type="Submit" name="Submit" value="Search">
</form>

This is the page in which the user's search is submitted to and brings up all data related to that search.

<?
      session_start();
      if(!session_is_registered(myusername)){
      header("location:main_login.php");
      }
?>

      <html>
      <head><title>Login Panel</title></head>

      <!-- stylesheets -->
      <link rel="stylesheet" href="style.css" type="text/css" media="screen" />

      <body>
      <?
      //connect to mysql
      //change user and password to your mySQL name and password
      mysql_connect("194.81.104.27","www","www") or die(mysql_error());

      //select which database you want to edit
      mysql_select_db("dbaleister") or die(mysql_error());

      $search=$_POST["search"];

      $factid = $_REQUEST["factid"];

      //get the mysql and store them in $result.
      //change whatevertable to the mysql table you're using.
      //change whatevercolumn to the column in the table you want to search.

      $result = mysql_query("SELECT * FROM fact,url,keyword WHERE factid = urlid AND factid = keyid AND title LIKE '%$search%'");

      //grab all the content.

      while($r=mysql_fetch_array($result))

      {

      //the format is $variable = $r["nameofmysqlcolumn"];

      //modify these to match your mysql table columns

      $factid=$r["factid"];
      $title=$r["title"];
      $paragraph=$r["paragraph"];
      $image=$r["image"];
      $keyid=$r["keyid"];
      $kword=$r["kword"];
      $urlid=$r["urlid"];
      $link=$r["link"];

      //display the row

      //echo "$title <br /> $paragraph";

      }
      ?>
      <!-- Main page starts here -->
  
      <div id="container">

      <div id="content" style="padding-top:50px;">

      <table id="main">

      <tr>
      <td>

      <table id="title">

      <tr>

      <td>

      <p><u>Title</u><h4><? echo "$title";?></h4></p>

      </td>

      </tr>
      </table><br />

      </td>

      <tr>

      <td>

      <table id="image">

      <tr>

      <td>

      <p><img src="<? echo "$image";?>"></p>

      </td>

      </tr>

      </table><br />

      </td>

      <td>

      <table id="paragraph">

      <tr>

      <td>

      <p><? echo "$paragraph";?></p>

      </td>

      </tr>

      </table><br />

      </td>

      </tr>

      <tr>

      <td>

      <table id="url">

      <tr>

      <td>

      <p><u>URL Address</u><br /><br /><a href="<? echo "$link";?>"><? echo "$link";?></a></p>

      </td>

      </tr>

      </table>

      </td>

      <td>

      <table id="keyword">

      <td>

      <p><u>Associated Keywords:</u><br /><br /><? echo "$kword";?></p>

      </td>

      </tr>

      </table>

      </td>

      </tr>

      </table>

      <br />

      <?
      //connect to mysql
      //change user and password to your mySQL name and password
      mysql_connect("194.81.104.27","www","www") or die(mysql_error());

      //select which database you want to edit
      mysql_select_db("dbaleister") or die(mysql_error());

      $result = mysql_query("SELECT factid,title FROM fact WHERE factid IN (SELECT fk2_factid FROM relationship WHERE fk1_factid = ".$factid.")");

      $factid=$r['factid'];

      echo "<table border='1' width='100%' cellpadding='20px'>
      <tr>

      <td align='center' colspan='2'><b>LIST OF RELATED FACTS</b></td>
      </tr>";

      while ($row = mysql_fetch_array($result)) {
      echo "<tr>";
      echo "<td>" . $row['factid'] . "</td>";
      echo "<td>" . $row['title'] . "</td>";
      echo "</tr>";
      }
      echo "</table>";
      ?>
      <br />

      <?
      //connect to mysql
      //change user and password to your mySQL name and password
      mysql_connect("194.81.104.27","www","www") or die(mysql_error());
      //select which database you want to edit
      mysql_select_db("dbaleister2") or die(mysql_error());

      $pathid = $_REQUEST["pathid"];

      $result = mysql_query ("SELECT pathid FROM lp ORDER BY pathid DESC LIMIT 0,1");

      echo "<center><table border='1' width='50%' cellpadding='20px'>

      <tr>
      <td align='center' colspan='2'><b>YOUR CURRENT LEARNING PATH IS:</b></td>
      </tr>";

      while ($row = mysql_fetch_array($result)) {
      echo "<tr>";
      echo "<td>" . $row['pathid'] . "</td>";
      echo "</tr>";
      }
      echo "</table></center>";
      ?>

      <br />
      <center><table border="1" width="20%" cellpadding="10px">

      <tr>
      <td align="center" colspan="2"><b>ADD THIS STEP TO LEARNING PATH</b></td>
      </tr>

      <tr>
      <td><center><form action="addfirstfact.php" method="post"><input type="submit" value="Add"></form></center></td>

      </tr>
      </table></center>

      <br />

      <table id="footer">
      <tr>
      <td>

      <p>Hello <?php echo $_SESSION['myusername'];?>, Would you like to <a href="logout.php">Logout?</a></p>
 
      </td>
      </tr>
      </table>
 
      <br /> <form method="link" action="search.php">
      <input type="submit" value="Back to Search">
      </form>

      </div><!-- content -->
      </div><!-- container -->
      </body>
      </html>

I want the two variable $factid and $pathid to be passed to this page so i could insert them in a table.

<?
      //connect to mysql
      //change user and password to your mySQL name and password

      mysql_connect("194.81.104.27","www","www") or die(mysql_error());

      //select which database you want to edit
      mysql_select_db("dbaleister2") or die(mysql_error());

      //GRAB THE VARIABLES
      $pathid = $_REQUEST["pathid"];
      $factid = $_REQUEST["factid"];

      mysql_query("INSERT INTO step VALUES (null, '$factid', 0, 0, '$pathid', 0)");

      header('Location: search2.php');
      ?>
2
Contributors
1
Reply
5
Views
7 Years
Discussion Span
Last Post by pbcomput
0
In Your second page code 

$factid = $_REQUEST["factid"];
$pathid = $_REQUEST["pathid"];

just assign them in session and you will got in your third page..
do like this in second page..

// for fatctid
$factid = $_REQUEST["factid"];
$_SESSION['factid'] = $factid;

// for pathid
$pathid = $_REQUEST["pathid"];
$_SESSION['pathid']= $pathid;

and call them on third page like this..

$factid = $_SESSION['factid'] ;
$pathid = $_SESSION['pathid'];

hope this will useful to you..:)

if any got problem in this just reply here....:)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.