Hi all,
Im relatively new to PHP, and i have come across a brick wall. What im trying to do is pass two variables $factid and $pathid to another PHP page and from there insert them into SQL Table. The only problem is that the $pathid is inside a while loop and $factid is echoed on the page from another query.
Both variables are integers so im puzzled why they are not echoing back.
Here is some of the code from a page called firstfact.php
<?
//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";
}
?>
<?
//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>";
?>
Here is the next page called addfirstfact.php, this is all of code.
<?
//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"];
echo '$pathid';
echo '<br /><br />';
echo '$factid';
echo '<br /><br />';
//mysql_query("INSERT INTO step VALUES (null, '$factid', 0, 0, '$pathid', 0)");
header('Location: search2.php');
?>
If you need anymore information, let me know and i can send the whole of the page source code.