MySQL Crash Course, Part 2
Subject:   Imbedding mysql source in objects
Date:   2004-01-23 07:32:58
From:   sunwalker
I need help. I'm into a problem where I need to execute some mysql code (PHP) in a delayed fashion. Basically it's a drop down menu, that needs to run when it's echoed to the browser, but not when it is first accessed. The reasoning is to have the mysql do it's thing from within a pre-made template, but not until then. Anyway, I'm preloading all the HTML and (hopefully) the PHP containing the mysql into strings and then echoing them from a function that spews out the code and executing the mysql code. Is this the correct way to do things? And if so how can I imbed the mysql code into my string? If not is there a better approach? I really don't have any experience with objects, so that may be a big part of my problem.

This is my code for the menu:

echo "<select name='MyCounty' size='1'>";
$query = "Select * from Counties ORDER BY County asc";
$result = mysql_query($query);
$RowNum = mysql_numrows($result);
$i = 0;
WHILE ($i < $RowNum) {
$row=mysql_fetch_array($result); $MCounty=$row["County"]; echo "<option value='$MCounty'>$MCounty</option>"; $i++;
echo "</select>";

1 to 1 of 1
  1. Imbedding mysql source in objects
    2004-04-16 13:13:49  willis1480 [View]

1 to 1 of 1