Reputation: 171
I'm trying to create a while loop that will go through my query results and output my php and html. I'm trying to figure out what is the best way to output the following code.
I tried to echo the link and because the php is inside it I was getting multiple errors.
I've tried google searching but I don't really know what to put down to start finding the answer.
<?php
while ($row = mysql_fetch_assoc($result)) {
<a href='#' data-reveal-id="echo $row["name"]" data-animation="none">
<div class="grid_3">
<p id="contexttitle"> echo $row[]; <span style="float:right;"> echo $row[]; </span> </p>
<p id="accesssubmenu">Last Update: echo $row[]; </p>
</div>
</a>
<div id="echo $row[];" class='reveal-modal'>
<h1> echo $row[]; </h1>
<p> echo $row[]; </p>
<p4>Last Update: echo $row[]; </p4>
<a class="close-reveal-modal">×</a>
</div>
}
?>
Upvotes: 0
Views: 108
Reputation: 2443
replace your code with this:
<?php
while ($row = mysql_fetch_assoc($result)) {
?>
<a href='#' data-reveal-id="<?php echo $row["name"] ?>" data-animation="none">
<div class="grid_3">
<p id="contexttitle"><?php echo $row[];?>
<span style="float:right;"><?php echo $row[];?> </span>
</p>
<p id="accesssubmenu">Last Update:<?php echo $row[];?> </p>
</div>
</a>
<div id="<?php echo $row[];?>" class='reveal-modal'>
<h1><?php echo $row[]; ?></h1>
<p><?php echo $row[]; ?> </p>
<p4>Last Update:<?php echo $row[];?> </p4>
<a class="close-reveal-modal">×</a>
</div>
<?php } ?>
Please specify field (column name) in $row[]
.
For example $row["field_name_here"]
.
Don't leave blank $row[]
.
Upvotes: 1
Reputation: 3665
You can't directly output HTML in PHP without either using a print/echo statement, or closing the PHP segment. For example, you can echo a list like this:
<?php
echo '<ul>'
for($x=0;x<$10;$x+=1){
echo "<li>$x</li>";
}
echo '</ul>';
?>
or you can close the php and write HTML directly:
<ul>
<?php for($x=0;$x<10;$x++){ ?>
<li><?php echo $x; ?></li>
<?php } ??
</ul>
Upvotes: 0