Hi,

I am a newbie to PHP and HTML and over here i am trying to display my sql results in a table format like this,

ID. Name. Contact
---------------------------------------------
----ROW1----------------------------------
----ROW2----------------------------------

any site recommendations where i can get help from? thanks alot.

Recommended Answers

All 4 Replies

http://www.w3schools.com/PHP/php_mysql_intro.asp

That should help! :)

Ah. :) thanks alot. but i have another problem again. what do they mean by,
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource ?

here is part of the code,

ORDER BY firstName ASC";

    $result = mysql_query($query); 

echo "<table border='1'>
        <tr>
        <th>ID</th>
        <th>FirstName</th>
        <th>LastName</th>
        <th>CompanyName</th>"

             while($row=mysql_fetch_row($result))
            {
                echo "<tr>";
                echo "<td>" .$row['ID']."</td>";
                echo "<td>" .$row['FirstName']."</td>";
                echo "<td>" .$row['LastName']."</td>";
                echo "<td>" .$row['CompanyName']."</td>";
echo "</table>";

so sorry to trouble you again. mind telling me where is my mistake? :)
Thanks again.

The simplest way to solve that error is to print out the query and execute it phpmyadmin / mysql console. You will know the exact problem. You can also try $result = mysql_query($query) or die (mysql_error()); to get the error message. Also, mysql_fetch_row should be used if you are using numeric index for your array. ie., $row[0], $row[1] and so on. If you want associated names, you should use mysql_fetch_array or mysql_fetch_assoc.

The simplest way to solve that error is to print out the query and execute it phpmyadmin / mysql console. You will know the exact problem. You can also try $result = mysql_query($query) or die (mysql_error()); to get the error message. Also, mysql_fetch_row should be used if you are using numeric index for your array. ie., $row[0], $row[1] and so on. If you want associated names, you should use mysql_fetch_array or mysql_fetch_assoc.

Ah, thanks alot. problem solved. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.