# Reading data from mysql, please help!

**URL:** <https://forum.kirupa.com/t/reading-data-from-mysql-please-help/185008>\
**Category:** flash\
**Created:** [April 10, 2006, 8:17am UTC](https://forum.kirupa.com/t/reading-data-from-mysql-please-help/185008 "2006-04-10T08:17:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tariqrf](https://avatars.discourse-cdn.com/v4/letter/t/b19c9b/32.png) [@tariqrf](https://forum.kirupa.com/u/tariqrf)\
**Post date:** [April 10, 2006, 8:17am UTC](https://forum.kirupa.com/t/reading-data-from-mysql-please-help/185008/1 "2006-04-10T08:17:16Z")

</div>

Reading from database.

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 10, 2006, 3:35pm UTC](https://forum.kirupa.com/t/reading-data-from-mysql-please-help/185008/2 "2006-04-10T15:35:28Z")

</div>

you will need to use xml probably. you can format your database into xml and pass it directly to your flash file if you like without creating a static file…

Based on the question im guessing you are a smarty

eg: in flash

```auto

// text field properties
with (head_txt) {
	html=true, wordWrap=true;
}
/*-------------------------------------------------------------------------

				load XML

-------------------------------------------------------------------------*/
blog_xml = new XML();
blog_xml.ignoreWhite = true;
blog_xml.onLoad = function(success) {
	if (success) {
		head_txt.htmlText = "";
		blog = this.firstChild.childNodes;
		for (e=0; e<this.firstChild.childNodes.length; e++) {
			my_author = blog[e].attributes.author;
			my_date = blog[e].attributes.date;
			my_blurb = blog[e].attributes.body;
			my_head = "Some freak by the name of "+my_author+" wrote... ";
			setText();
		}
		
	} else {
		my_txt.text = "Error!";
	}
};
head_txt.text = "Loading...";
blog_xml.load("xml-6.php");
/*-------------------------------------------------------------------------

				display it

-------------------------------------------------------------------------*/
function setText() {
	head_txt.htmlText += my_head+"<br>";
	head_txt.htmlText += my_date+"<br><br>";
	head_txt.htmlText += my_blurb+"<br><br>";
}

```

this is what xml-6.php looks like

```php

<?php
$host = "localhost";
$user = "root";
$pass = " **********";
$database = "test";
$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 articles ORDER BY id";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>
";
$xml_output .= "<entries>
";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
    $row = mysql_fetch_assoc($resultID);
    $xml_output .= "<entry";
    $xml_output .= " author=\"" .$row['posted_by']. "\"";
    $xml_output .= " date=\"" .$row['created_at']. "\"";
$row['body'] = str_replace("\"", "'", $row['body']);
    $xml_output .= " body=\"" . $row['body'] . "\"";
    $xml_output .= ">blah";
    $xml_output .= "</entry>
";
}

$xml_output .= "</entries>";
//$xml_output = str_replace("&", "and", $xml_output);
//$xml_output = str_replace("\"", "&quote", $xml_output);
print $xml_output;
?>

```

attached below is an sql dump you can put into your database for the testing the above code.

I would recommend using a duplicated or attached movieclip which contains both a text field and a movieclip.  
you can load your image onto the clip with a link you supply via a row in your table. and the text from another row.

Hope this helps

:mario:

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 10, 2006, 3:41pm UTC](https://forum.kirupa.com/t/reading-data-from-mysql-please-help/185008/3 "2006-04-10T15:41:49Z")

</div>

also place each next item based at the last items height + your spacing value

and place all of this info within a scroller (like kirupas one in source and experiments)

then for the buttons on the left… well someone else may answer that better

---

<div class="post-metadata">

**Author:** ![tariqrf](https://avatars.discourse-cdn.com/v4/letter/t/b19c9b/32.png) [@tariqrf](https://forum.kirupa.com/u/tariqrf)\
**Post date:** [April 10, 2006, 4:47pm UTC](https://forum.kirupa.com/t/reading-data-from-mysql-please-help/185008/4 "2006-04-10T16:47:04Z")

</div>

Reading from database.

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 10, 2006, 11:32pm UTC](https://forum.kirupa.com/t/reading-data-from-mysql-please-help/185008/5 "2006-04-10T23:32:46Z")

</div>

> [@tariqrf](#):
>
> how do i get the ‘image path in database’ as its in a mysql table in binary form!!???

I didnt think this was possible with mySQL. Sorry dont know how to do that. I always use text only.

looks like you understand what to do to me.

however check below this may help
