
Originally Posted by
Darchangel
sorry, didn't know you were putting it in the middle of html. in that case, don't forget to surround the code with <?php ?>
also, i obviously don't know the context of your full code but your foreach sections look odd. is $data a multi-dimentional array of your entire db results?
Sorry, I don't even know! This is all new to me. I've been trying to make a database-driven website, using tutorials and online forums, and I've received so many alternate strategies, I feel like I've created a quilt. 
This is what my primary query looks like:
PHP Code:
<?php
mysql_connect ("localhost" , "USERNAME" , "PASSWORD") or die(mysql_error());
mysql_select_db ("DATABASE") or die(mysql_error());
$qry = "SELECT * FROM basics as b, famarea as f, bushnations as bn, bushstates as bs
WHERE bn.IDArea = b.IDArea and bs.IDArea = b.IDArea and f.IDArea = b.IDArea and b.IDArea = '$mycode'";
$result = mysql_query($qry);
$type = mysql_fetch_array($result);
$mytype = "my" . $type['TypeArea'];
$$mytype = $type['Name'];
if (phpversion() <= "4.1.0") { $vars = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS); } else { $vars = $_REQUEST; }
$area_code_sql = mysql_query("SELECT *
FROM basics as b, famarea as f, bushnations as bn, bushstates as bs
WHERE bn.IDArea = b.IDArea and bs.IDArea = b.IDArea and f.IDArea = b.IDArea and and b.IDArea = '".$mycode);
$type = mysql_fetch_assoc($result);
$mytype = "my" . $type['TypeArea'];
$data = array();
$data_details = mysql_fetch_assoc(mysql_query("SELECT *
FROM basics WHERE IDArea LIKE '$mycode'"));
/*
$query = "SELECT * FROM bushnations WHERE IDArea like '$mycode'";
*/
$query = "SELECT famarea.*, bushnations.* FROM famarea, bushnations
WHERE bushnations.IDArea = famarea.IDArea
AND famarea.IDArea like '$mycode'";
$data = array();
if ($res = mysql_query($query)) { while ($temp = mysql_fetch_assoc($res)) { $data[] = $temp;} };
$foo = array("us-", "ca-");
$mycode = str_replace($foo, "", $mycode);
?>
I have an array in my head section, but I can't even remember what it was intended for - or if it's even functioning. I just kept it as a reference, so I'll know how to make an array when I really need one.
Thanks.
Bookmarks