MySQL Forums
Forum List  »  PHP

PDO ITERATION
Posted by: David Goodnature
Date: March 01, 2011 04:35PM

*********I call this function:

function get_press_data() {

global $db_sterling;

$query = "SELECT *
FROM presses
ORDER BY location ASC, revSize ASC";

$press_data = $db_sterling->query($query);

return $press_data;

}

************in a webpage using:

$presses = get_press_data();

*************later in the page, I iterate over the list using:

<table>
<tr>
<th>Code</th>
<th>Name</th>
<th>Location</th>
<th>Size</th>
<th>Units &frasl; Hr</th>
<th>Start Time</th>
<th>&nbsp;</th>
</tr>
<?php foreach ($presses as $press) : ?>
<tr>
<FORM action="index.php" method="post">
<input type="hidden" name="action" value="edit_press_specs" />
<input type="hidden" name="pressid" value='<?php echo $press['pressID']; ?>' />
<td><?php echo $press['pressID']; ?></td>
<td><?php echo $press['pressName']; ?></td>

<td><input type="input" name="location"
value = '<?php echo $press['location']; ?>'
size = "3" maxlength="3" /></td>

<td><input type="input" name="revsize"
value = '<?php echo $press['revSize']; ?>'
size = "2" maxlength="2" /></td>

<td><input type="input" name="unitsperhour"
value = '<?php echo $press['unitsPerHour']; ?>'
size = "6" maxlength="6" /></td>

<td><input type="input" name="starttime"
value = '<?php echo $press['startTime']; ?>'
size = "6" /></td>

<td><input type="submit" value="SUBMIT" /></td>
</FORM>
</tr>
<?php endforeach; ?>
</table>

******Everything works great, BUT - - - - - -

I need to iterate over the same list again. I want to start over later in the page and display some "other stuff". I'm presenting different parts of the data from this query in different places.

I'm sure there is some way to do this without performing the same query again, but I can't figure it out.

Thanks in advance.

Options: ReplyQuote


Subject
Written By
Posted
PDO ITERATION
March 01, 2011 04:35PM
March 05, 2011 03:46PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.