|
Posted by Cool Shaker on 08/17/06 16:50
Hi
Before I go completely mad I would like to ask for the assistance of people
in this group please.
I have a test web page which is linked to a database, no problem there.
A list is populated from the databse and currently has three items in it.
The idea is that the full record from the database will be passed across to
another page to be displayed. I have not changed it to open the second page
yet until I debug the first bit.
If I pick the first item in the list and click the go button the debug echos
show data from the correct record. Since I want to pass this data to another
page I am using hidden inputs to do the passing as the data will be way in
excess of 100 characters.
I also show the hidden field to see what it thinks should be passed across.
The strange thing is that once the first record data is shown in the $myrow
echos the hidden field $toptitlx is blank.
Select the second record in the list and the myrows show the correct data
but $toptitlx shows data from the first record.
Pick the thirds record, the $myrow shows the correct data and $toptitlx
shows the second record data.
Now even stranger, if I look at the soucre code of the page in the browser
the data is correct and both the $myrow and $toptitlx are the same.
A link to this page is http://www.libraryclub.co.uk/test.php
My code is as follows
<?php
include 'opendb.php';
//**********************************************************
// Build content of list
//**********************************************************
$sqlstring= "select id, memoryno , title from mems2 order by memoryno";
$result=mysql_query($sqlstring) or die('Could not find the table');
//*****************************************************
// Do list
//*****************************************************
echo (" <div id='list'> ");
echo ("<form name='form2' method='post' action=''>
<select name='selectedmemory'> ");
echo (" <option value=0>Select a memory from this list</option> ");
//set up first entry in list asking the user to select a memory
while ($myrow=mysql_fetch_row($result))
{
$memnumber = $myrow[1] ;
while (strlen($memnumber ) < 4)
{
$memnumber = "0" . $memnumber;
}
echo (" <option value=$myrow[0]>$memnumber - $myrow[2]</option> ");
}
echo ("</select>");
echo ("<input name='findmemory' type='submit' id='findmemory'
value='Go'>");
//echo("</form> ");
//echo (" </div> ");
//**************************************************************************************************************************
// Select only the record picked from the list - if no record picked
i.e. when the page loads for the first time, do nothing
//**************************************************************************************************************************
if (!isset($selectedmemory))
{
$selectedmemory = 1;
} else {
$sqlstring= "select * from mems2 where id = $selectedmemory";
$result=mysql_query($sqlstring) or die('could not find $sqlstring');
$myrow=mysql_fetch_row($result);
}
//echo ("<INPUT TYPE='HIDDEN' NAME='toptitlx' value='" . $myrow[2] "'/>
");
echo ("<input name='toptitlx' type='hidden' value='$myrow[2]'/>");
echo ("<input name='toptitlx2' type='text' value='$myrow[2]'/>");
//echo "<BR>";
//echo "No 0 " .$myrow[0];
//echo "<BR>";
//echo "No 1 " .$myrow[1];
echo "<BR>";
echo "No 2 " .$myrow[2];
//echo "<BR>";
//echo "No 3 " .$myrow[3];
//echo "<BR>";
//echo "No 4 " .$myrow[4];
//echo "<BR>";
//echo "No 5 " .$myrow[5];
//echo "<BR>";
//echo "No 6 " .$myrow[6];
echo "<BR>";
echo "toptitlx " .$toptitlx;
echo "<BR>";
echo("</form> ");
echo (" </div> ");
include 'closedb.php';
?>
And the page source is as follows
<div id='list'> <form name='form2' method='post' action=''>
<select name='selectedmemory'> <option value=0>Select a memory from
this list</option> <option value=1>0001 - One - the first memory</option>
<option value=2>0002 - The second memory</option> <option value=3>0003 -
The third memory</option> </select><input name='findmemory' type='submit'
id='findmemory' value='Go'><input name='toptitlx' type='hidden' value='The
third memory'/><input name='toptitlx2' type='text' value='The third
memory'/><BR>No 2 The third memory<BR>toptitlx The second memory<BR></form>
</div>
I have looked at this for so long now I doubt I would see the problem so any
help would be appreciated.
Many thanks
Navigation:
[Reply to this message]
|