SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Design trouble

  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Design trouble

    I'm trying to create a table layout to display information in an orderly way. My code is messed up somewhere, was wondering if i could get some hints.

    Code:
    .......
    while($xpl = mysql_fetch_array($xplist)){
    
    echo "<table border="1" width="100&#37;">";
    echo	"<tr>";
    echo		"<td width="249">";
    echo		"<p align="center">Date</td>";
    echo		"<td width="120">";
    echo		"<p align="center">Start XP</td>";
    echo		"<td width="120">";
    echo		"<p align="center">Finish XP</td>";
    echo		"<td>";
    echo		"<p align="center">Info</td>";
    echo	"</tr>";
    echo	"<tr>";
    echo		"<td width="249">".$xpl['date']."</td>";
    echo		"<td width="118">"$xpl['startxp']."</td>";
    echo		"<td width="119">".$xpl['finxp']."</td>";
    echo		"<td>".$xpl['info']."</td>";
    echo	"</tr>";
    echo "</table>";
    echo "<br />";
    I've tried changing it a couple different ways i can't get it to display at all.

    Thanks

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    One tip I would give you is to get rid all of those echo statements. Embed the PHP into your HTML instead of the other way around. It will be easier to read and debug in this case.

  3. #3
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    probably a dumb question (brand new to php) but you mean something like this?

    Code:
    while($xpl = mysql_fetch_array($xplist)){
    <html>
    <table border="1" width="100%">
    	<tr>
    		<td width="249">
    		<p align="center">Date</td>
    		<td width="120">
    		<p align="center">Start XP</td>
    		<td width="120">
    		<p align="center">Finish XP</td>
    		<td>
    		<p align="center">Info</td>
    	</tr>
    	<tr>
    		<td width="249">echo $xpl['date'];</td>
    		<td width="118">echo $xpl['startxp'];</td>
    		<td width="119">echo $xpl['finxp'];</td>
    		<td>echo $xpl['info'];</td>
    	</tr>
    </table>
    </html>
     "<br />";
    Thanks!

  4. #4
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't have the time to fix yours but this is a example that I used a few weeks back that is what stymiee means:

    PHP Code:
        echo <<<eof
    <form action="admin.php?mode=delete" method="post">
    <table width="80%" border="1">
      <tr>
          <td>Delete</td>
        <td>Name</td>
        <td>Address</td>
        <td>Phone Number </td>
        <td>Email</td>
        <td>Credit Card Number </td>
        <td>Credit Card Type </td>
        <td>Expiration Month </td>
        <td>Ex. Year </td>
        <td>CC Verification </td>
        <td>Message</td>
        <td>Price</td>
        <td>Date Submitted</td>
      </tr>
    eof;

    while(
    $row mysql_fetch_array($resultMYSQL_ASSOC))
    {
        
        
        
        echo 
    "
    <tr>
        <td><input name=\"del["
    .$row['id']."]\" type=\"checkbox\" value=\"1\" />
        <td>"
    .($row['name'])."</td>\n
        <td>"
    .($row['address'])."</td>\n
        <td>"
    .($row['phonenumber'])."</td>\n
        <td>"
    .($row['email'])."</td>\n
        <td>"
    .($row['ccnum'])."</td>\n
        <td>"
    .($row['cctype'])."</td>\n
        <td>"
    .($row['exmonth'])."</td>\n
        <td>"
    .($row['exyear'])."</td>\n
        <td>"
    .($row['ccnver'])."</td>\n
        <td>"
    .($row['message'])."</td>\n
        <td>"
    .($row['price'])."</td>\n
        <td>"
    .($row['time'])."</td>\n
      </tr>"
    ;
        
        
       
             
        

    How does that make your feel?

  5. #5
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that got me started!!

  6. #6
    SitePoint Enthusiast stevem01's Avatar
    Join Date
    Apr 2001
    Location
    Modesto, CA
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This type of multi-line string creation is called "Heredoc" syntax. You can find more by Googling: php heredoc

    It really comes in handy sometimes, but always look for ways to templatize if it's warranted. Hope that helps.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •