Results 1 to 9 of 9

Thread: More Complex Restructuring

  1. #1

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459

    Angry More Complex Restructuring

    Hi!

    Here more complex resturcturing of data whihc i have totally failed to do.

    Currently i get records from mysql in the following format:

    id 1
    desc 1
    id 2
    desc 2
    id 3
    desc 3
    id 4
    desc 4

    id # and desc # are 1 record displayed in 2 lines. for eg. echo $a1[id];
    echo "<br>\n";
    echo $a1[desc];

    now i want to have them using tables in the following format:

    id 1 id 2
    desc1 desc 2
    id 3 id 4
    desc3 desc 4

    Is this possible ? very urgent please help i wasted my whole day and got nothing

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  2. #2
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    If you couldn't figure this out from the previous question you asked, maybe you should consider a different career.

    It's all about building strings and putting them together for your final result.

    You can't build a table column by column. You have to build it row by row.

    PHP Code:
    $i 1;
    while(
    $row mysql_fetch_array($result))
    {
    if(
    $i == 1)
    {
    $str1 "<tr><td>" $row['id'] . "</td>";
    $str2 "<tr><td>" $row['desc'] . "</td>";
    }
    else
    {
    echo 
    $str1 "<td>" $row['id'] . "</td></tr>"
    echo 
    $str2 "<td>" $row['desc'] . "</td></tr>";
    $i 0;
    }
    $i++;

    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Hi ober!

    I don't you scolding me..as i am newbie in php and you're an expert. Anyways i tried your code it works if there are even records in database like 0, 2, 4, 8 but if there are odd records in database like 1,3,5,7,9 then it eats up the last record it should display and only displays odd even records.

    Can you help me fix this ?

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  4. #4
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Add the following after the code I gave you before (outside the while loop):
    PHP Code:
    if($i == 2)
    {
    echo 
    $str1 "<td>&nbsp;</td></tr>"
    echo 
    $str2 "<td>$nbsp;</td></tr>";

    And I am far from an expert. It's all about logical thinking and picturing in your head what you want to accomplish. And this question was only a minor twist from the previous one. It shouldn't have been much of a stretch of the imagination. I apologize if I have offended you.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  5. #5

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    No problem! I appericiate your help! Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Ober, you weren't being offencive.

    PHP.net has an excellent online manual with a functios able to accomplish almost any task, especially with regards to string manipulation. I was once a PHP newbie and in many ways I still ma, I make extensive use of the manual and very rarely need to post a question.

    90% of the questions I answer in this forum a just links to the online manual with the function they need. We can all search the internet and find them ourselves and in some cases thats what I do for other people. My view is, if you want someone to write the code for you then send us money and we will be happy to assist. If you have a genuine problem which you are struggling to solve and have exhausted all avenues then post here and we are happy to assist for free
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Hi visualAd

    i am sorry to say that i have manual also..and it integreats into my php editor by pressing f1 i can get the help. but i don't think that questions i asked are mentioned anywhere in manual. Also i doubt if anyone has asked this type of question before on this forum i wrote whole of the code myself..i was just getting stuck at this one..which i asked.

    I am sorry if i am asking too much. I must find some other place then. Sorry again!

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  8. #8
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    No, you don't need to find another place. I get stuck on stuff too sometimes and I have no problem helping someone out of a jam. Sometimes you need a second pair of eyes.

    However, if you are looking for a forum that has more traffic in terms of PHP help, check out www.phpfreaks.com I frequent there and questions are answered more quickly because there are more people to answer them.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  9. #9

    Thread Starter
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Thanks ober! I appericiate this i will go and join there now! Thanks again!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

Posting Permissions

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



Click Here to Expand Forum to Full Width