Jump to content

mySQL database assistance needed :)


disturbed

Recommended Posts

I'm not very skilled in working with mysql, but i try :) I would really appreciate anyone willing to help me with this, its not really hard, but i still dont know how to do this....

I have a mysql database I want to print stuff out off - its simply a collection of data - so how would i go about printing this out in a webpage ?

Link to comment
Share on other sites

yeah....im aware of that .... i was trying to use a php serverside script - the script goes something like the following

<?php

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

$host = "localhost";

$user = "edited";

$pass = "edited";

$database = "edited";

$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");

mysql_select_db($database, $linkID) or die("Could not find database.");

$query = "SELECT * FROM `formNo1` WHERE 1";

$resultID = mysql_query($query, $linkID) or die("Data not found.");

$xml_output = "<?xml version="1.0"?>n";

$xml_output .= "<entries>n";

for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){

    $row = mysql_fetch_assoc($resultID);

    $xml_output .= "t<entry>n";

    $xml_output .= "tt<date>" . $row['date'] . "</date>n";

        // Escaping illegal characters

        $row['text'] = str_replace("&", "&", $row['text']);

        $row['text'] = str_replace("<", "<", $row['text']);

        $row['text'] = str_replace(">", ">", $row['text']);

        $row['text'] = str_replace(""", """, $row['text']);

    $xml_output .= "tt<text>" . $row['text'] . "</text>n";

    $xml_output .= "t</entry>n";

}

$xml_output .= "</entries>";

echo $xml_output;

?>

Link to comment
Share on other sites

just change this section


    $xml_output .= "tt<date>" . $row['date'] . "</date>n";
        // Escaping illegal characters
        $row['text'] = str_replace("&", "&amp;", $row['text']);
        $row['text'] = str_replace("<", "&lt;", $row['text']);
        $row['text'] = str_replace(">", "&gt;", $row['text']);
    $xml_output .= "tt<text>" . $row['text'] . "</text>n";
[/php]

Link to comment
Share on other sites

hrm i use this to store / retrieve a Team event list

BTW if you see some code in here thats not standard php its because im using this as a postnuke module

DBINFO


<?PHP
$db_host = 'localhost';
$db_name = 'edit';
$db_user = 'edit';
$db_pass = 'edit';
?>
[/code]

Index

[code]

mysql_connect($db_host,$db_user,$db_pass);

@mysql_select_db($db_name) or die( "Unable to select database");

$query="SELECT * FROM events";

$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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