SQL query and HTML Tables

Thread Solved

Join Date: May 2008
Posts: 29
Reputation: heels is an unknown quantity at this point 
Solved Threads: 0
heels heels is offline Offline
Light Poster

SQL query and HTML Tables

 
0
  #1
May 26th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,747
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: SQL query and HTML Tables

 
0
  #2
May 26th, 2008
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 29
Reputation: heels is an unknown quantity at this point 
Solved Threads: 0
heels heels is offline Offline
Light Poster

Re: SQL query and HTML Tables

 
0
  #3
May 26th, 2008
Originally Posted by nav33n View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,747
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: SQL query and HTML Tables

 
0
  #4
May 26th, 2008
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.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 29
Reputation: heels is an unknown quantity at this point 
Solved Threads: 0
heels heels is offline Offline
Light Poster

Re: SQL query and HTML Tables

 
0
  #5
May 28th, 2008
Originally Posted by nav33n View Post
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC