Jump to content

[SOLVED] While statment Dosnt show first Value??


AE117

Recommended Posts

Heres the Code

 

header("Content-Type: text/xml");

$table_id = 'ost_media';
$query = "SELECT * FROM $table_id";
$dbresult = mysql_query($query, $dbconnect);

$outer_table = 'ost_media';
$queryB = "SELECT * FROM ost_media WHERE media_title='1997 Eagle Talon'";
$resouter = mysql_query($queryB, $dbconnect);

$inner_table = 'ost_media';
$query = "SELECT * FROM $inner_table WHERE media_access='private'";
$resinner = mysql_query($query, $dbconnect);

$dom = new DomDocument('1.0','utf-8');

$root = $dom->createElement('featureset');
$root = $dom->appendChild($root);

$row = @mysql_fetch_assoc($resouter);

// process all rows of the inner/many/child table
while ($row = @mysql_fetch_assoc($resinner)) {
    // add node for each record
$outer = $dom->createElement('album');
$outer = $root->appendChild($outer);
    $outer->setAttribute('name', 'Shock Value');
$outer->setAttribute('author', 'Timbaland');
$outer->setAttribute('imageUrl', 'images/Timbaland/image.jpg');
$outer->setAttribute('link', 'http://flabell.com/');
    // add a child node for each field
    while ($queryB = @mysql_fetch_assoc($resouter)) {
$inner = $dom->createElement('song');
    $inner = $outer->appendChild($inner);
$inner->setAttribute('name', 'name');
$inner->setAttribute('duration', '3:15');
$inner->setAttribute('buy', 'false');
$inner->setAttribute('download', 'true');
$inner->setAttribute('downloadsource', 'download/song1.mp3');
$value = $dom->createTextNode('songs/song1.mp3');
$value = $inner->appendChild($value);

    } // foreach

} // while


// get completed xml document
$xml_string = $dom->saveXML();
echo $xml_string;

?>

 

Now heres the problem,

 

The second while  with in the first while is calling to the query $resouter which must equal $queryB

and as you can see i have $queryB that is set to equal a title "1997 Eagle Talon" There are actually two of these values with in the table but it only shows one of them.

 

Then lets say I have a title called A and I have 100 of them it will show 99 of them

 

THen lets say I have one entry to equal 18 it will show nothing.

 

For some reason it is not showing the first value. Does anyone see anything I am doing wrong???

 

Thanks

Remove

<?php
$row = @mysql_fetch_assoc($resouter);
?>

before you do your first while. You are getting and not using the first record here.

 

Ken

 

O God I feel like such and Idiot Thank You much that solved it, i need to get off this computer sometime lol.

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.