By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,691 Members | 1,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,691 IT Pros & Developers. It's quick & easy.

Simply Syntax Question

P: 52
Hello All,

I have a simply syntax question. I'm new to PHP, but I have worked with ASP for years. Can you reference a database field on an html page with PHP the same way you can with ASP. For example in ASP you can have something like so...

Expand|Select|Wrap|Line Numbers
  1. <td width="100%"><%=recordset("somecolumn")%></td>
However, I've noticed in PHP you must do something like this...

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. while (odbc_fetch_row($set))
  3. {
  4.     $var=odbc_result($set,"somefield");
  5.   echo "<td class='paratext'>$var</td>";
  6. }
  7. ?>
Is there a way to short cut it? Maybe something like this...

Expand|Select|Wrap|Line Numbers
  1.   echo "<td class='paratext'>" & odbc_result($set,"somefield") & "</td>";

Oct 12 '07 #1
Share this Question
Share on Google+
2 Replies

P: 16
Try the "." opperator:
Expand|Select|Wrap|Line Numbers
  1. echo "<td class='paratext'>" . odbc_result($set,"somefield") . "</td>";
Oct 12 '07 #2

Expert 5K+
P: 5,821
When echoing, it's actually more efficient to use commas:

Expand|Select|Wrap|Line Numbers
  1. echo '<td class="paratext">', odbc_result( $set, 'somefield'), '</td>';
Oct 12 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.