5 messages in com.mysql.lists.mysqlRe: select statement not working in a...| From | Sent On | Attachments |
|---|---|---|
| Chip Wiegand | 22 Mar 2004 09:33 | |
| Rick Emery | 22 Mar 2004 09:50 | |
| Diana Cristina Neves Soares | 22 Mar 2004 10:04 | |
| Chip Wiegand | 22 Mar 2004 10:47 | |
| beac...@misc.com | 22 Mar 2004 11:26 |
| Subject: | Re: select statement not working in a php page![]() |
|---|---|
| From: | Rick Emery (rem...@emeryloftus.com) |
| Date: | 03/22/2004 09:50:37 AM |
| List: | com.mysql.lists.mysql |
What result are you getting?
First off, I see that your HTML is possibly incorrect; should it be: echo "<td>Warranty ID:</td>\n";
<th> is a table header.
Second, if you are expecting a single result row, then you do not need the
while() loop. Do a
single fetch and display the result.
rick "People will forget what you said. People will forget what you did. But people will never forget how you made them feel."
----- Original Message ----- From: "Chip Wiegand" <chip...@simrad.com> To: "MySQL " <mys...@lists.mysql.com> Sent: Monday, March 22, 2004 11:33 AM Subject: select statement not working in a php page
I am trying to get a single result from a database, which works fine at the sql command line. I have tried several versions of code, this being the most recent - <? $sql = "select max(WarrantyID) from warrantycopy"; $result=mysql_query($sql) or die("Could not get the id number :" . mysql_error()); while($query_data = mysql_fetch_array($result)) { $WarrantyID = $query_data["WarrantyID"]; echo "<tr>\n"; echo "<th>Warranty ID:</th>\n"; echo "<td>$WarrantyID</td>\n"; echo "</tr>\n"; } ?> No matter what I do I do not get the desired max id number from the column WarrantyID. The same query works fine at the sql command line. What am I doing wrong? thanks
-- Chip
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=rem...@emeryloftus.com




