Php Record set query

Discussion in 'QnA (read only)' started by Butterfly, Dec 14, 2004.

Thread Status:
Not open for further replies.
  1. Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Ok Dude,

    I wanted php record set , i can get the data from database very easily but am not gettting the data in the wayu i wanted it ..

    this is wat oi get from database ,

    Tile|Content| Link
    Tile|Content|Link
    Tile|Content| Link

    what my want is not in vertical i wanted in horizantol loop, like this

    Titile1 | Titile2 | Titile2 |
    Content|Content|Content|
    Link | Link Link | Link Link

    in this way , if u dont get me , let me mail u
     
  2. flashweb

    flashweb New Member

    Joined:
    Nov 27, 2004
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    <table>
    
    <?php
    
    while($myrow=mysql_fetch_array($result)) {
    
    echo "
    <TR>
    <TD>
    <table>
    <TR><TD>$myrow["Title"]</TD></TR>
    <TR><TD>$myrow["Content"]</TD></TR>
    <TR><TD>$myrow["Link"]</TD></TR>
    </table>
    </td>
    </tr>
    ";
    
    }
    
    ?>
    
    </table>
    
    
    Hope it helps.
     
  3. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    O Flash,

    Thanks for coding , sadly ur codeing i couldnt use it, i got puzzeled, hey u mind if u look into my coding , i have givein the table also, plz hlp am running into this proble for so long ! Thakns i will really appreciate u

    Codings

    ***********************************************************

    <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_conn = "localhost";
    $database_conn = "tol";
    $username_conn = "root";
    $password_conn = "";
    $conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>


    <?php require_once('file:///C|/web/tol.com/Connections/conn.php'); ?>
    <?php
    $maxRows_Recordset1 = 3;
    $pageNum_Recordset1 = 0;
    if (isset($_GET['pageNum_Recordset1'])) {
    $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
    }
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

    mysql_select_db($database_conn, $conn);
    $query_Recordset1 = "SELECT title, content, link FROM news";
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
    $Recordset1 = mysql_query($query_limit_Recordset1, $conn) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);

    if (isset($_GET['totalRows_Recordset1'])) {
    $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
    } else {
    $all_Recordset1 = mysql_query($query_Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
    }
    $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <table width="150" border="1">
    <?php do { ?>
    <tr>
    <td><?php echo $row_Recordset1['title']; ?></td>
    </tr>
    <tr>
    <td><?php echo $row_Recordset1['content']; ?></td>
    </tr>
    <tr>
    <td><?php echo $row_Recordset1['link']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </table>

    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>


    Table
    **********************************************************

    # Table structure for table `news`
    #

    CREATE TABLE `news` (
    `id` int(10) unsigned NOT NULL auto_increment,
    `title` varchar(200) NOT NULL default '',
    `content` longtext NOT NULL,
    `author` varchar(20) NOT NULL default '',
    `link` varchar(100) NOT NULL default '',
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=10 ;

    #
    # Dumping data for table `news`
    #

    INSERT INTO `news` VALUES (1, 'JPEG', 'WindowPCs that are unpatched are vulnerabe to attacks by harmless image files. Picture in the JPEG ', 'karma', 'click more');
    INSERT INTO `news` VALUES (3, 'Thsechu', '<img src=http://localhost/tol.com/images/mask.jpg width=47 height=47 border=1>\r\n <img src=http://localhost/tol.com/images/phob.jpg width=47 height=47 border=1>
    \r\nForm of arts and craft through \r\n centuries of influence by its culture...', '', 'click more');
    INSERT INTO `news` VALUES (4, 'Highlights', '<img src=http://localhost/tol.com/images/mask.jpg width=47 height=47 border=1>\r\n <img src=http://localhost/tol.com/images/phob.jpg width=47 height=47 border=1>
    \r\nForm of arts and craft through \r\n centuries of influence by its culture...', 'asasa', 'click more');
     
  4. flashweb

    flashweb New Member

    Joined:
    Nov 27, 2004
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    0
    FileName : test.php

    Code:
    
    <?php 
    # FileName="Connection_php_mysql.htm" 
    # Type="MYSQL" 
    # HTTP="true" 
    $hostname_conn = "localhost"; 
    $database_conn = "test"; 
    $username_conn = "root"; 
    $password_conn = ""; 
    $conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR); 
    ?> 
    
    
    <?php 
    
    #require_once('file:///C|/web/tol.com/Connections/conn.php'); 
    
    ?> 
    
    <?php 
    $maxRows_Recordset1 = 3; 
    $pageNum_Recordset1 = 0; 
    if (isset($_GET['pageNum_Recordset1'])) { 
    $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; 
    } 
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; 
    
    mysql_select_db($database_conn, $conn); 
    $query_Recordset1 = "SELECT title, content, link FROM news"; 
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); 
    $Recordset1 = mysql_query($query_limit_Recordset1, $conn) or die(mysql_error()); 
    $row_Recordset1 = mysql_fetch_assoc($Recordset1); 
    
    if (isset($_GET['totalRows_Recordset1'])) { 
    $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; 
    } else { 
    $all_Recordset1 = mysql_query($query_Recordset1); 
    $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); 
    } 
    $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; 
    ?> 
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
    <title>Untitled Document</title> 
    </head> 
    
    <body> 
    <table border="1"> 
    <tr valign=top>
    
    <?php do { ?> 
    <td>
    <table width="150">
    <tr> 
    <td><?php echo $row_Recordset1['title']; ?></td> 
    </tr> 
    <tr> 
    <td><?php echo $row_Recordset1['content']; ?></td> 
    </tr> 
    <tr> 
    <td><?php echo $row_Recordset1['link']; ?></td> 
    </tr> 
    </table>
    </td>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> 
    </tr>
    </table> 
    
    </body> 
    </html> 
    <?php 
    mysql_free_result($Recordset1); 
    ?>
    
    

    Hope this is what you want...
     
  5. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Flash,

    Thanks a lot, is it working fine ,Let me try it , if erros i will get back to you.

    Happy New Year
     
  6. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Flash,

    Thanks a lot , it worked finally , umm little not ok what i wanted , well if u look at the last row, "clickmore" cant that be in same line so that it looks consitent , as per me , the content somtimes gets more and less so if the last is is in the same row or in tr , that would solvbe my prob, reallyu sorry for the cause and tropuble to u ..

    thanks
    [/url]
     
  7. Deep

    Deep Version 2.0

    Joined:
    Jan 23, 2004
    Messages:
    977
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai
    I think cutting down the characters would help you..

    u can use substr function to cut the string...

    example..
    Code:
    <?php
    $orig_string ="1234567890";
    $cut_string = substr("$orig_string", 0,5); // will return 12345
    $final_string = $cut_string. "... ". [url="#"]click for more[/url]"; // shall show 12345... click more 
    ?>
    I hope this is what you wanted..

    cheers
    Deep
     
  8. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Folk,

    no thats not what i wanted, what i mean to tell is that , every thing is ok,, just that "clickmore" part well u look at it clealy u will see one "clickmore" is bit tilted and the other column "clickmore" is in the line , so what i mean to say is that , when i add information into "content" that dosent effect the "clickmore" consistent , i wanted in the same line no matter wat the "content" might less or more , hope u understantd what i have mentioned.. ok if u go through my coding u will i guess..

    thanks again for ur precious time that i took !

    Merry Christnmas and HappyNewyear too
     
Thread Status:
Not open for further replies.

Share This Page