Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8168577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:34:23+00:00 2026-06-06T20:34:23+00:00

How can I get the code below to output node names that I define?

  • 0

How can I get the code below to output node names that I define? As of now, it creates the nodes based on column names of an SQL table. I want to define both the columns and the nodes. Also, how can I code it so that when someone inserts data into my table it appends that data to the inserted data? E.g.:

Input data: "davidjmorin"
Data inserted: "http://someurl.com/davidjmorin"

Here is my code for the original question:

<?
//header('Content-type: text/xml');

$link = mysql_connect('localhost','root','IhaveAlLthEanSwers2012!');
mysql_select_db('bb_links');

$sql = "Select * from `links`";
$run = mysql_query($sql, $link);

if( $run && mysql_num_rows( $run ) ) {
$doc = new DOMDocument( '1.0' );
$doc->formatOutput = true;
$doc->preserveWhiteSpace = true;

$root = $doc->createElement( 'data' );
$doc->appendChild( $root );

while( ( $fetch = mysql_fetch_assoc( $run ) )!== false ) {
    $node = $doc->createElement( 'channel' );
    $root->appendChild( $node );

    foreach( $fetch as $key => $value ) {
        createNodes( $key, $value, $doc, $node );
    }
}
$doc->save("thelinks.xml");
}
//$node = "channel";
function createNodes( $key, $value, $doc, $node ) {
$key = $doc->createElement( $key );
$node->appendChild( $key );
$key->appendChild( $doc->createTextNode( $value ) );
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:34:25+00:00Added an answer on June 6, 2026 at 8:34 pm

    I’m not entirely sure what you’re asking in your first question, but for your second question (which really should be split up into a second question on here), I think what you’re asking is just basic string concatenation. For example,

    <?php
        $url_name = "http://www.example.com/";
        $data = $_POST['name']; //davidjmorin
        $data_to_insert = $url_name . $data;
        //Insert data into database
    ?>
    

    Also, please don’t use mysql_* functions for new code. They are no longer maintained and the community has begun the deprecation process (see the red box). Instead, you should learn about prepared statements and use either PDO or MySQLi. If you can’t decide which, this article will help you. If you care to learn, this is a good PDO tutorial.

    I’m serious. Don’t use those functions. At all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

any idea how i can get the code below to produce this output? 1
I have a piece of code (below) that can get the text of an
Is there an ide/site that I can use to analyse code below and get
I can't get the code below to compile (see errors). Advice on correction would
I can't get fancybox to open my links in iframe. My code below. Thanks!
I ended up with this horrible code below, I can't get a better result
I can't get this code to work. Declared playpauseButton just above the given below
Below is a cut down example of some c# code I can't get to
Where can I get a code snippets for VC++ that can be used with
I can't get to the bottom of why my output variable in the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.