This is my page from an online radio station site of mine on localhost, it's a basic PHP/MySQL one for test purposes:

    <?php
mysql_connect('localhost', 'root', 'mypass') or die (mysql_error());
mysql_select_db('radiotest') or die (mysql_error());
$result = mysql_query("SELECT *, TIME_FORMAT(airtime, '%H:%i') `airtime` 
from presenters");
//Table starting tag and header cells
while($row = mysql_fetch_array($result)){
//Display the results in different cells
echo "<dd><dl><img src=' " . $row['image'] . " '>" . $row['airtime'] ." 
" . $row['presenter'] . "</dd></dl>";
echo "<dd><dl>" . $row['showinfo'] . "</dd></dl>";
}
?>

It works properly, displays the data from the table in the required format.

However, I want to try doing it this way:

<dd><dl><img src='<?php echo $row['image'] ?'> <?php echo $row['airtime']?> 
 <?php echo. $row['presenter']?> </dd></dl>

My problem: I admit I've forgotten how to do echo without displaying it in the PHP/MySQL query like above, so how can I ensure it displays the variables using echo without having to declare it in the MySQL connection? I know my original is correctly formatted, but I don't want it to have the echo variables after the while part of the syntax, I wanted to echo them within the dd / dl HTML (definition list).

Basically, I'm just trying to brush up my skills in this area; had a look on Google but am not quite sure

Any help is appreciated!

link|improve this question
Your code already looks formated and im not sure what you re trying to ask here. – swordfish Aug 25 '11 at 22:33
feedback

2 Answers

It's really no different, and definitely not better, but I think you are asking to do:

while($row = mysql_fetch_array($result)){
//Display the results in different cells
?>
<dd><dl>
    <img src='<?php echo $row['image']; ?>'>
    <?php echo $row['airtime']; ?> <?php echo $row['presenter']; ?>
</dd></dl>
<dd><dl>'<?php echo $row['showinfo']; ?></dd></dl>
<?php
}
link|improve this answer
feedback

Try this instead:

<dd>
    <dl>
        <img src='<?=$row['image'] ?>'> <?=$row['airtime'] . " - " .$row['presenter']?> 
    </dd>
</dl>
link|improve this answer
Are short tags really necessary? – Problematic Aug 25 '11 at 22:36
what's wrong with short tags? i'm not getting paid by code length :) – iHaveacomputer Aug 25 '11 at 23:09
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.