Jump to content

how to retrieve value from multiple db tables


mpsn

Recommended Posts

Hi, I want to be able to retrieve records from db tables to build an xml file. The problem I am having is that I don't know how to retrieve a value after using foreign key to get appropriate value. You see below I want to make a new attribute to store to var $newAttr.

 

<?php
$doc=new DOMDocument();
mysql_connect("localhost","root");
mysql_select_db("xmlDB");

$edges=mysql_query("SELECT * FROM edge");
while($row=mysql_fetch_assoc($edges)) {
if($row['flag']=='val') {
	$curValue=mysql_query("SELECT val FROM value,edge WHERE val.edge_id=edge.edge_id");
	if($curRowIsAttribute=mysql_query("SELECT is_Attribute FROM value,edge WHERE value.is_Attribute='Y' AND value.edge_id=edge.edge_id")) {
		//create attribute node
		$newAttr=$dom->createAttribute();//HELP HERE PLEASE THEN I SHOULD BE ABLE TO COMPLETE NEXT TWO LINES BELOW!

		//set attribute value
		...

		//append attribute to current element
		...	

		}//END IF
	}//END IF
}//END BIG WHILE 
?>

 

Any help much appreciated!

not exactly sure what you're after... or what value you're trying to assign...  current value?

$doc=new DOMDocument();
mysql_connect("localhost","root");
mysql_select_db("xmlDB");

$edges=mysql_query("SELECT * FROM edge");
while($row=mysql_fetch_assoc($edges)) {
if($row['flag']=='val') {
	$curValue=mysql_query("SELECT val FROM value,edge WHERE val.edge_id=edge.edge_id");
	if($curRowIsAttribute=mysql_query("SELECT is_Attribute FROM value,edge WHERE value.is_Attribute='Y' AND value.edge_id=edge.edge_id")) {
		//create attribute node
$currentValue=mysql_result($curValue,0); //will retrieve val from the $curValue sql query - you can use mysql_fetch_assoc etc which is more efficient though in this situation you can play around with it... 
		$newAttr=$dom->createAttribute($currentValue);//HELP HERE PLEASE THEN I SHOULD BE ABLE TO COMPLETE NEXT TWO LINES BELOW!

		//set attribute value
		...

		//append attribute to current element
		...	

		}//END IF
	}//END IF
}//END BIG WHILE 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.