Echo while, without using a table?

Discussion in 'PHP' started by Matt Ridge, Sep 23, 2011.

  1. #1
    Is there a way to do an echo while loop without using a table?

    The example I have is:

    echo '<table>';
      while ($row = mysqli_fetch_array($data)) { 
    Code (markup):
    I really don't want to use a table.
     
    Matt Ridge, Sep 23, 2011 IP
  2. jevchance

    jevchance Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Not enough information. What data are you trying to display? There are numerous ways to display the data, none of them have to do with PHP.

    For example, you could display them using <pre>.

    You could also format using CSS.

    Also, there's nothing wrong with using tables, especially for tabular data.

    Again, what is it you are trying to display?
     
    jevchance, Sep 23, 2011 IP
  3. Matt Ridge

    Matt Ridge Peon

    Messages:
    166
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Matt Ridge, Sep 23, 2011 IP
  4. jevchance

    jevchance Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    2
    Trophy Points:
    0
    #4
    What you can do is take the exact same code you use to display the form, and instead of text fields, you just output the associated data from the recordset.

    For example:

    
    <fieldset>
    		<div id ="added">    
    			<label>Added By:</label>
    			<?php echo $row['Added_By']; ?>
    			<label>on:</label>
    			<?php echo $row['Added_By_Date']; ?>
    		</div>	
    		
    	<div id="box">	
    		<div id ="part">
    			<label>Nexx Part:</label>
    			<?php echo $row['Nexx_Part']; ?><br />
    			<label>Nexx Rev:</label>
    			<?php echo $row['Nexx_Rev']; ?><br />
    			<label>Nexx Part Description:</label>
    			<?php echo $row['Nexx_Part_Description']; ?><br />
    
    Code (markup):
    etc...
     
    jevchance, Sep 23, 2011 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    If you're sending the form to the user, and then you want to stuff it with data, Use AJAX. (I can't post a whole AJAX tutorial here, but there are hundreds of them on the web. The easiest way to do it is with jQuery.)
     
    Rukbat, Sep 25, 2011 IP