Select from mysql and export to a htm file with php!!

Hello everyone?
A bookmark file look like this (a very simple one!)::


Bookmarks

Bookmarks

SBm - date

User Interface Design GmbH (UID) - Usability Engineering, Graphic Design, Software Development
User Interface Design, Usability, Human Factors, & Ergonomics

What I need to do is to get from a database a name of site (site_name) and de link of the site (site_link) and put it in the spotes it has to be in! example:::


Bookmarks

Bookmarks

SBm - date

site_name
site_name

And export it to a file (ex: bookmark.htm).

In the [ ADD_DATE=“0000000000”] I can use <?php date("Y-m-d"); ?>

Thanks? a real thanks

What have you tried so far? Where did you get stuck?

I made it and tested the bookmark (import)…

What’s your code look like so far?

:D

the problem is that what I did nothing works!

Well, what worked ‘best’? Show us that code then.

We’re not going to just do your job and give you perfectly working code, even if we could. We can point you in the right direction though:

  • open database connection

  • query all relevant data

  • close database connection

  • open file pointer

  • write all relevant data (including surrounding tags)

  • close file pointer

I don’t wnat perfectly working code… :lol: defore I posted I really tried… but nothing!

here is what i’ve done::

<?php include './bd_sbm.php'; $result=mysql_query("select bookmarks_link, bookmarks_nome_site from bookmarks where utilizadores_id= 4;"); $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = " Bookmarks

Bookmarks

SBm - date

"; while($row = mysql_fetch_array($result)) $stringData2 = "

".$row[1].""

"; fwrite($fh, $stringData); fwrite($fh, $stringData2); fclose($fh); mysql_close(); ?>


but nothing…

Okay … have you tried debugging? As in, error_reporting(E_ALL), print_r() and echo?

hello…

it works! bu only to write a file but I have another problem!

it should look like this::

Bookmarks

Bookmarks

<DT><H3 FOLDED ADD_DATE="0000000000">SBm - date</H3>
	<DL><p>
		<DT><A HREF="http://www.uidesign.de/index.php?article_id=1&clang=1" >User Interface Design GmbH (UID) - Usability Engineering, Graphic Design, Software Development</A>
		<DT><A HREF="http://www.usernomics.com/" >User Interface Design, Usability, Human Factors, & Ergonomics</A>
	</DL><p>


but it looks like this::

Bookmarks

Bookmarks

	<DT><H3 FOLDED ADD_DATE='2007-06-13'>SBm - 2007-06-13</H3>
		<DL><p>
			<DT><A HREF=http://www.google.pt>google</A>
			<DT><A HREF=http://www.fnac.pt>fnac</A>
			<DT><A HREF=http://www.google.pt>google</A>
		</DL><p>
</DL><p>

::> the problem is that

ADD_DATE=‘2007-06-13’ should look like this::>
ADD_DATE=“0000000000”
I dont know how to put the -> " <-
and the same thing with

it should look like this::
HREF=“
http://www.google.pt” >

again I dont know how to put (print out !!) the -> " <-

thank Zyppora

<?php include './bd_sbm.php'; $result=mysql_query("select bookmarks_link, bookmarks_nome_site from bookmarks where utilizadores_id= 4;"); $myFile = "bookmark.htm"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = " Bookmarks

Bookmarks

SBm - ".date("Y-m-d")."

"; fwrite($fh, $stringData); while($row = mysql_fetch_array($result)) { $stringData2 = "

".$row[1]." "; fwrite($fh, $stringData2); } $stringData3 = "

"; fwrite($fh, $stringData3); mysql_close(); fclose($fh); ?>


[url]http://php.morva.net/manual/pt_BR/language.types.string.php

finaly it’s done… :)[/url]

Sponsor our Newsletter | Privacy Policy | Terms of Service