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
Related Q & A:
- How to parse .log file and insert into database in PHP?Best solution by unix.com
- How to connect to a Pervasive Database using javascript?Best solution by Stack Overflow
- How to store an image in database using MySQL?Best solution by stackoverflow.com
- How to Connect to Remote Oracle Database through PHP?Best solution by Stack Overflow
- How do I display limited html content in a webview?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.