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!

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.