Ok picture the scene MySQL Table spec1, spec2, spec3 ... upto spec50

now they will contain data upto any given field and not beyond so if spec30 has a value and spec31 does not spec1 - spec30 will all contain data.

what I am trying to do is page the results in groups of 10 printing a more (Next) link for the next set of data if the first field in that group contains data if it does not I want to print a close window link instead..

of course I have made a right mess of it .. Please can someone help me out. 🙂

thanks all in advance...

<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); 
		$myPage = $ix+ 1;
		$npage = $page + 1;
		$nextpage = "spec$myPage";
		$Mnextpage = $row_Recordset1['spec$myPage'];
		echo $row_Recordset1['spec$myPage'];
		if(is_null($Mnextpage)){
		?>
		<br>
		<a href="javascript:window.close;">Close Window</a>
		<?php
		}else{
		?>
		<a href="fullspec_popup.php?handset=<?php echo $myTariff;?>&page=<?php echo $npage;?>">More</a>
		<?php } ?>

    I'm having a bit of trouble following your code, but I do see something that could be making it go wrong.

    First line should be:

    while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) {

    Notice that it ends with a bracket ( { ) instead of a semicolon. If you just do the semicolon, it will end the while loop right there, and then only execute the stuff below it once.

    Also, a couple suggestions:

    1) Use the

     tag instead of the [code] tag, it makes the PHP look all pretty. Not to mention it's easier to read.
    2) You may want to learn how to use [URL=http://www.php.net/echo]echo[/URL] or [URL=http://www.php.net/print]print[/URL]. You don't have to use the <? ?> tags every time you want to output something, that's just a waste of time and it makes your code more confusing.
    3) Not sure why you need 50 columns, but there's probably a much better way to do it.

      Hi thanks for your response.

      Its a product feed which goes into a mysql database each field contains a specifiaction there can be upto 50 per product what I would do in ASP is

      grab the recordset and stuff it into an array using getrows then loop through the array testing the next value as I went for Null then exit the for loop in php I have no clue 🙂

      somthing like:

      for i = to Ubound(MyArray)
      testVar = i + 1
      if isNull(MyArray(testVar)) then
      Exit for
      else
      response.write(MyArray(i)&"<br>")
      End if
      Next

      of course I would page it as well

      OOh Forgot to add I have all 50 fields open in a recordset thats why it ends there

      I loop from $page (1 if $page is not set) to $page + 10 then in the bit pasted I check page+ 10 + 1 to see if it has a value then make the fieldnames up using 'spec$i' type thing 🙂

        Here's pseudo code for how I'd do it:

        while ($row = fetch_row($res)){
            foreach($row as $r){
                if (!is_null($r)){
                    print $r;
                }
            }
        }
        
          Write a Reply...