Hi - I've been racking my brain on this one - have searched the web and read - and still cannot figure it out. Help!
Here's what I'm trying to do:
I want to output all the rows of this query on different places of the same page. There will be 7 or 8 blocks of text - complete with a header, some decriptive comments and a link. I'm trying to load as much as possible into the initial queries when the page is loaded - then output variables from different queries later in the page.
Here's the problem:
I believe the answer is in looping through the result set by row - one row at a time - and outputting the fields from each row. I just can't seem to get the syntax right. The pseudo code would be:
Pseudo Code
Goto Row 1
Print Out the Entity Name for Row 1
Print Out the Entity Description for Row 1
Print Out the Entity URL for Row 1
Goto Row 2
Print Out the Entity Name for Row 2
Print Out the Entity Description for Row 2
Print Out the Entity URL for Row 2
Goto Row X (as long as there are rows in the lookup table)
...Print Out the Entity Name for Row X
...Print Out the Entity Description for Row X
...Print Out the Entity URL for Row X
Here's the query code:
<?
/ Declare DB and User Variables /
$dbhost = "my.server.com";
$dbuser = "leftblank";
$dbpass = "leftblanktoo";
$dbname = "somedatabase";
$dbtable = "sometable";
/ Query - Get All Main Section Variables for Use/
mysql_connect($dbhost,$dbuser,$dbpass) or die("Unable to connect to database!");
@mysql_select_db("$dbname") or die("Unable to select database $dbname!");
$sqlentityquery = "SELECT * FROM $dbtable WHERE '1'";
$result = mysql_query($sqlentityquery) or die("Couldn't execute query!");
/ Prepare Display /
while ($row = mysql_fetch_array($result))
{
$entity_pk = $row['ENTITY_PK'];
$entity_id = $row['ENTITY_ID'];
$entity_name = $row['ENTITY_NAME'];
$entity_url = $row['ENTITY_URL'];
$entity_image = $row['ENTITY_IMAGE'];
$entity_description = $row['ENTITY_DESCRIPTION'];
/ Display Variables with consistent color scheme /
echo "<A HREF = '$entity_pk'>$entity_pk</a> <p>";
echo "<A HREF = '$entity_id'>$entity_id</a> <p>";
echo "<A HREF = '$entity_name'>$entity_name</a> <p>";
echo "<A HREF = '$entity_url'>$entity_name</a> ";
echo "<A HREF = '$entity_image'>$entity_image</a> <p>";
echo"<A HREF = '$entity_description'>$entity_description</a> <p>";
}
?>
Thanks
Konaman