You are here: Re: Is it PHP or is it an HTML problem « All PHP « IT news, forums, messages
Re: Is it PHP or is it an HTML problem

Posted by J.O. Aho on 08/17/06 17:24

Cool Shaker wrote:
> 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]'/>");

The value is from the previous time the page is shown, so if you go to the
page for the first time and pick one option and press on the Go button, you
will get the toptitlx as an empty data, as when the page is loaded for the
first time, the variable $myrow is empty. This leads the whole time that you
will get the previous times selection.


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация