Link to home
Start Free TrialLog in
Avatar of babak62
babak62

asked on

do while loop

Hi everybody;
I am trying to print my records in this table but i know that the syntax is not correct.  What I need to do is to have a do loop to repeat the table and a while look inside to generate the rows based on the query.  Please tell me what is the right syntax as if I play with this more I might screw the rest of the work too.

    print "<table width=\"1000\\ border='1'\" align=\"center\">";
    //
            
     echo "   
      
        do
    {
      
            { while($row = mysql_fetch_array ($result))

          <tr height='10'>
            <td class='textlinkTitle'  height='20'>                  
             <a href=media_page.php?media_id=$row[Media_ID]>$row[Media_Name]</a>       
            </td>
          </tr>";

      echo " 
          <tr height='5'>
            <td class='textlinkDescription' height='5'>
             
                    ".limitWords($row['Description'], 30) . "..."."
            </td>
          </tr>
          <tr class= 'textlinkURL'height='5' >
            <td  height='5'>
              ".$row['URL']."<hr SIZE=1 width='800' />  
            </td>
          </tr>";
           
    print "</table>";
      } while ($row_row = mysql_fetch_array ($result))
Avatar of Salih Maoui
Salih Maoui
Flag of Algeria image

Hi

your syntax is not correct  
while PHP

try this code
$list = '<table width="1000" border="1" align="center">';	 
	  
      while($row = mysql_fetch_array ($result))
	  {

       $list = $list. '  <tr height="10">
            <td class="textlinkTitle"  height="20">                  
             <a href=media_page.php?media_id='.$row[Media_ID].'>'.$row[Media_Name].'</a>        
            </td>
          </tr>
    
          <tr height="5">
            <td class="textlinkDescription" height="5"> 
              
                    '.limitWords($row['Description'], 30) . '...
            </td>
          </tr>
          <tr class= "textlinkURL" height="5" >
            <td  height="5">
              '.$row['URL'].'<hr SIZE=1 width="800" />  
            </td>
          </tr>';
        }      
		
    $list = $list. "</table>";
	echo $list // or print $list

Open in new window

Avatar of babak62
babak62

ASKER

thanks for the answer it prints the list but gives me this error before that

Notice: Use of undefined constant Media_ID - assumed 'Media_ID' in C:\wamp\www\PhpIran-test\Bko\client_media_search.php on line 84


line 84 is

 <a href=media_page.php?media_id='.$row[Media_ID].'>'.$row[Media_Name].'</a>        
ASKER CERTIFIED SOLUTION
Avatar of Salih Maoui
Salih Maoui
Flag of Algeria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of babak62

ASKER

Indeed.  Such a great job and help thanks a lot for helping me.