PHP MYSQL<?php echo $ row [$ variable]; ?> [英] PHP MYSQL <?php echo $row[$variable]; ?>

查看:65
本文介绍了PHP MYSQL<?php echo $ row [$ variable]; ?>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码可以实现我想要的功能,但是反斜杠<?php echo $ row [\’t_id\’]; ?> <?php echo $ row [\’t_type\’]; ?> <?php echo ucfirst $ row [\'t_fn\'])。\'& nbsp; \'.ucfirst( $ row [\'t_ln\']); ?> 不输出它们各自的变量。

I have the following code that does what I want it to do, but the ones with the backslashes <?php echo $row[\'t_id\']; ?>, the <?php echo $row[\'t_type\']; ?> and the <?php echo ucfirst$row[\'t_fn\']).\'&nbsp;\'.ucfirst($row[\'t_ln\']); ?> do not output their respective variable.

相反,它们的输出像

view_t_profile.php?tutor_id=<?php echo $row['t_id']; ?>&t_type=<?php echo $row['t_type']; ?>

<?php echo ucfirst $ row ['t_fn']) 。'& nbsp;'。ucfirst($ row ['t_ln']); ?> 不会像以前的代码那样显示在网页上,而是以斜体显示为红色文本。我不是程序员,所以如果有人可以更正我的代码,我肯定会感激的。通常,我可以弄清楚,但是在这一点上,我不知道。

The <?php echo ucfirst$row['t_fn']).'&nbsp;'.ucfirst($row['t_ln']); ?> doesn't show up on the web page like the previous code, but its in the code italicized and in red text. I'm not a programmer/coder, so if someone can correct my code, I sure would appreciate it. Usually, I can figure it out, but on this one, I cannot.

<?php

if($row['t_type'] == 1)

{

echo '<center><strong><font color="#3BB9FF"><a href="view_t_profile.php?t_id=<?php echo $row[\'t_id\']; ?>&t_type=<?php echo $row[\'t_type\']; ?>" class="cls" target="_blank"><br />View Profile</a></font></strong></center>';
echo '<center><strong>Main Contact</strong></center>';
echo '<center><strong><font color="#3BB9FF"><?php echo ucfirst$row[\'t_fn\']).\'&nbsp;\'.ucfirst($row[\'t_ln\']); ?></font></strong></center>';

}

if($row['t_type'] == 0)

{

echo '<center><strong><font color="#3BB9FF"><a href="view_t_profile.php?t_id=<?php echo $row[\'t_id\']; ?>&t_type=<?php echo $row[\'t_type\']; ?>" class="cls" target="_blank"><br />View Profile</a></font></strong></center>';
echo '<center><strong>Main Sponsor</strong></center>';
echo '<center><strong><font color="#3BB9FF"><?php echo ucfirst$row[\'t_fn\']).\'&nbsp;\'.ucfirst($row[\'t_ln\']); ?></font></strong></center>';

}

?>


推荐答案

您不使用 <?php echo ...?> 当您已经处于PHP模式并回显某些内容时。只需连接变量即可。

You don't use <?php echo ... ?> when you're already in PHP mode and echoing something. Just concatenate the variable.

echo '<center><strong><font color="#3BB9FF">' . ucfirst($row['t_fn']) . '&nbsp;' . ucfirst($row['t_ln']) . '</font></strong></center>';

<?php echo ...?> 在您仅直接输出HTML并想要插入一些PHP时使用。例如,像这样:

<?php echo ... ?> is used when you're just outputting HTML directly, and you want to insert a bit of PHP. For instance, like this:

if($row['t_type'] == 1)
{ ?>
<center><strong><font color="#3BB9FF"><a href="view_t_profile.php?t_id=<?php echo $row['t_id']; ?>&t_type=<?php echo $row['t_type']; ?>" class="cls" target="_blank"><br />View Profile</a></font></strong></center>
<center><strong>Main Contact</strong></center>
<center><strong><font color="#3BB9FF"><?php echo ucfirst$row['t_fn']).'&nbsp;'.ucfirst($row['t_ln']); ?></font></strong></center>
<?php
}

这篇关于PHP MYSQL&lt;?php echo $ row [$ variable]; ?&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆