Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Is there any auto add PHP script?

  1. #1
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Is there any auto add PHP script?

    NOTE: sorry im double posting in the javascript and php forum. Im not sure which code language will be able to do what i need.

    I have a HUGE SQL file with 1000s of queries, but i need to convert that to xml. It is the Quran (huge holy book) and i need to covert it to xml for a module i am making for Joomla.

    Here is an example of one line
    Code:
    INSERT INTO quran VALUES (1, 'The Opening', 1, 1, '1 . In the name of Allah , the Beneficent , the Merciful');
    There are thousands of lines like this one.


    Bascially <query> before every INSERT INTO quran it detects? And insert a </query> after every )' it detects?

    If thats not possible, is there any code that will insert a </query><query> after every enter it detects?

    Or is this kind of job not possible with Javascript? Maybe PHP?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Sep 2006
    Location
    Eureka, California
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    sartajc,

    Can you please post a real example of BOTH what the present format is, and the format of what you want.

    I've done this dozens of time for different versions of the Bible... I just need to know exactly what format you want your .xml structor.

  4. #4
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    O ok. Heres an example of the line:

    Now it is:

    Code:
    INSERT INTO quran VALUES (1, 'The Opening', 1, 1, '1 . In the name of Allah , the Beneficent , the Merciful');
    INSERT INTO quran VALUES (2, 'The Opening', 1, 2, '2 . Praise be to Allah , Lord of the Worlds ,');
    INSERT INTO quran VALUES (3, 'The Opening', 1, 3, '3 . The Beneficent , the Merciful .');
    I need this:

    Code:
    <query>INSERT INTO quran VALUES (1, 'The Opening', 1, 1, '1 . In the name of Allah , the Beneficent , the Merciful');</query>
    <query>INSERT INTO quran VALUES (2, 'The Opening', 1, 2, '2 . Praise be to Allah , Lord of the Worlds ,');</query>
    <query>INSERT INTO quran VALUES (3, 'The Opening', 1, 3, '3 . The Beneficent , the Merciful .');</query>
    There is obviously more than 3 lines. It goes on for 1000s of lines.

  5. #5
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    You can use some text editor which supports RegEx search and replace operations. (PSPad ...)

  6. #6
    Join Date
    Sep 2006
    Location
    Eureka, California
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Uhh, how is that example you posted "converting it to xml"?

    Proper XML for this would be (something like):

    Code:
    <item>
    	<title>The Opening</title>
    	<chapter>1</chapter>
    	<verse>1</verse>
    	<description>
    		<![CDATA[1 . In the name of Allah , the Beneficent , the Merciful]]>
    	</description>
    </item>
    <item>
    	<title>The Opening</title>
    	<chapter>1</chapter>
    	<verse>2</verse>
    	<description>
    		<![CDATA[2 . Praise be to Allah , Lord of the Worlds ,]]>
    	</description>
    </item>
    <item>
    	<title>The Opening</title>
    	<chapter>1</chapter>
    	<verse>3</verse>
    	<description>
    		<![CDATA[3 . The Beneficent , the Merciful .]]>
    	</description>
    </item>
    That's what you really asked for...

    But what it sounds like what you've meant is to simply (a/pre)pend something to every line of your .sql file.

    In which case, just do what DimX suggested... replace on "INSERT INTO" and ");" ... and you should be done in about 20 seconds.

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    If you want the above, just have php output all the rows, and getting the data from each row.

    so....
    echo "stuff".$row['data1']."morestuff".$row......;



    http://php-mysql-tutorial.com
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33
    If you want the above, just have php output all the rows, and getting the data from each row.

    so....
    echo "stuff".$row['data1']."morestuff".$row......;



    http://php-mysql-tutorial.com

    ehh...i have no diea what you mean. im not PHP fluent. can you be more specific?

  9. #9
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by AbelaJohnB
    Uhh, how is that example you posted "converting it to xml"?

    Proper XML for this would be (something like):

    Code:
    <item>
    	<title>The Opening</title>
    	<chapter>1</chapter>
    	<verse>1</verse>
    	<description>
    		<![CDATA[1 . In the name of Allah , the Beneficent , the Merciful]]>
    	</description>
    </item>
    <item>
    	<title>The Opening</title>
    	<chapter>1</chapter>
    	<verse>2</verse>
    	<description>
    		<![CDATA[2 . Praise be to Allah , Lord of the Worlds ,]]>
    	</description>
    </item>
    <item>
    	<title>The Opening</title>
    	<chapter>1</chapter>
    	<verse>3</verse>
    	<description>
    		<![CDATA[3 . The Beneficent , the Merciful .]]>
    	</description>
    </item>
    That's what you really asked for...

    But what it sounds like what you've meant is to simply (a/pre)pend something to every line of your .sql file.

    In which case, just do what DimX suggested... replace on "INSERT INTO" and ");" ... and you should be done in about 20 seconds.

    No, thats not what i want at all. Im making an XML file for an extension im making for Joomla, and when someone uploads the xml file onto their joomla it gets executed. And in an XML install file, <query></query> will run a MySQL query. thats why i need <query></query> surrounding all the 1000s of queries i need to run.

  10. #10
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Help... i have no idea what that means.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •