|
Posted by George Webb on 12/26/06 15:54
adlerweb wrote:
> George Webb schrieb:
>> Within the script is
>> a sql query that selects * from mytable. The result is that all my
>> records are shown except the first record in the table which is stripped
>> from the results. If I modify the query to select the name of the
>> person who is shown in the first record I get zero results. A direct
>> MYSQL query produces the desired result.
>
> No, there should be no problem with PHP. You have not provided your code
> so i cant say whats wrong. Review your code and read the manual.
>
> Florian
Thanks. Here is the script in question:
<?php
$host= "host";
$user= "user";
$password= "";
$database = "mydb";
$mysql = mysql_connect($host, $user, $password);
if (!$mysql=mysql_connect($host, $user, $password)) {
printf("Connect failed: %s\n", mysql_connect_error());
exit();
mysql_close($mysql);
}
// Select Database
$db=mysql_select_db('mydb',$mysql)
or die ("Couldn't select database.");
// Get Data
$name = "My Table";
$query= "SELECT * FROM members ORDER BY lname";
$result = mysql_query($query)
or die ("Couldn't execute query.");
$row = mysql_fetch_array($result);
$name = ucfirst($name);
//Display results in a table
echo "<h1>$name</h1>";
echo "<table cellspacing = '15'>";
echo "<tr><td colspan = '5'><hr></td></tr>";
while ($row =mysql_fetch_array($result))
{
extract($row);
echo "<tr>\n
<td>$id</td>\n
<td>$fname</td>\n
<td>$lname</td>\n
<td>$address</td>\n
<td>$phone</td>\n
<td>$email</td>\n
</tr>\n";
echo "<tr><td colspan='5'><hr></td></tr>\n";
}
echo "</table>\n";
Navigation:
[Reply to this message]
|