How to display HTML data from database?

How to display in html my database using php?

  • How do i display a single entry from my database using php? I am able to display my database in an html. But I was wondering how to display the data of only a particular entry using my index field. Is this possible? I tried using where but i think there is something wrong with my code. Here is my code: mysql_connect(localhost,$username,$pas… @mysql_select_db($database) or die( "Unable to select database"); $query = "SELECT * FROM `tablename` WHERE `RefId`= '3165' DESC LIMIT 0, 100 "; $result=mysql_query($query); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><p align="center" class="body11px">Request<br/>ID</p></th> <th><p align="center" class="body11px">Name</p></th> <th><p align="center" class="body11px">Email</p></th> <th><p align="center" class="body11px">Phone</p></th> <th><p align="center" class="body11px">Mobile</p></th> </tr> <?php $f1=mysql_result($result,"RefId"); $f2=mysql_result($result,"Name"); $f3=mysql_result($result,"Email"); $f4=mysql_result($result,"Phone"); $f5=mysql_result($result,"Mobile"); ?> <tr> <td><p align="right" class="body11px"><?php echo $f1; ?></p></td> <td><p align="center" class="body11px"><?php echo $f2; ?></p></td> <td><p align="center" class="body11px"><?php echo $f3; ?></p></td> <td><p align="center" class="body11px"><?php echo $f4; ?></p></td> <td><p align="center" class="body11px"><?php echo $f5; ?></p></td> </tr>

  • Answer:

    Your query is not valid SQL. Firstly, table names and field names should not be surrounded by single quotes. They should stand alone or be surrounded by brackets. Secondly, desc is only to be used in the order by clause. Lastly, I have no idea what you are trying to do with limit. E-mail me if you have any questions. -Benjamin

RickyG at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.