0

hey m a newbie in php i would love some help on this one i have a section of jokes in my page the problem is i want the two columns 'name' and 'content' to be extracted from database and automatically put in a table where name is a title and content is the text part and i want the script to make a table each time they get a row with pagination ,,thanks and id love the help thanx

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by diafol
0

OK, where's your code? Post what you have and we'll have a look at it.
If you don't have any code at all, you came to the wrong place and should use Google to search for a script.

0
<?php

$hostname = 'localhost';
$username = 'root';
$password = 'polka.9``';
$db = 'pakhub';


$global_dbh = mysql_connect($hostname, $username, $password)
or die("Could not connect to database");
mysql_select_db($db, $global_dbh)
or die("Could not select database");
function display_db_query($query_string, $connection, $header_bool, $table_params) {
    // perform the database query
    $result_id = mysql_query($query_string, $connection)
    or die("display_db_query:" . mysql_error());
    // find out the number of columns in result
    $column_count = mysql_num_fields($result_id)
    or die("display_db_query:" . mysql_error());
    // Here the table attributes from the $table_params variable are added
    print("<TABLE $table_params >\n");
    // optionally print a bold header at top of table
    if($header_bool) {
        print("<TR>");
        for($column_num = 0; $column_num < $column_count; $column_num++) {
            $field_name = mysql_field_name($result_id, $column_num);
            print("<TH>$field_name</TH>");
        }
        print("</TR>\n");
    }
    // print the body of the table
    while($row = mysql_fetch_row($result_id)) {
        print("<TR ALIGN=LEFT VALIGN=TOP>");
        for($column_num = 0; $column_num < $column_count; $column_num++) {
            print("<TD>$row[$column_num]</TD>\n");
        }
        print("</TR>\n");
    }
    print("</TABLE>\n"); 
}

function display_db_table($tablename, $connection, $header_bool, $table_params) {
    $query_string = "SELECT * FROM jokes";
    display_db_query($query_string, $connection,
    $header_bool, $table_params);
}
?>

<TABLE><TR><TD>
<?php

$table = "table1";

display_db_table($table, $global_dbh,
TRUE, "border='2'");
?>
</TD></TR></TABLE>

the problem is this code create the table itself i want the data to be stored in a array so i can select the first arrays and show it in an html table

Edited by Nick Evan: Fixed formatting

0

OK, can you post this again and place the code within [ CODE ] tags?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.