Re: I've done the searching
Forgot to mention I'm using SQL 4.1 if that matters.
Re: I've done the searching
I believe it doesn't like the I think this is used in classes wich are objects, and your code is not object oriented. what is your goal? Somethng like this?
Code:
<?php
$dbhost = 'localhost';
$dbname = 'dbname';
$dbUser = 'dbUser';
$dbPass = 'dbPass';
if (!@mysql_connect($dbhost,$dbUser,$dbPass) or !@mysql_select_db($dbname)){
echo "No database connection";
}
$query = "select column1, column2 from my table";
$Statement = mysql_query($query);
while($myid = mysql_fetch_array($Statement)) {
$column1 = $myid["column1"];
$column2 = $myid["column2"];
echo $column1."<br>\n";
echo $column2."<br>\n";
}
?>
Re: I've done the searching
Quote:
Originally Posted by
bobo
I believe it doesn't like the
I think this is used in classes wich are objects, and your code is not object oriented. what is your goal?
Trying to extract table fields, group by 'name', then eventually display in a table.
Re: I've done the searching
oops we submitted at the same time, look above, just echo your TRs and TDs where I got my echo
Re: I've done the searching
I'll try to plug that in and see what happens. Thanks. I'll reply the results.
Re: I've done the searching
here is a full example that I actually use on my local server. Excuse the french text
where you see the include of connection.php, you wont need that, this is the same connection stuff as above.
Code:
<table width="560" border="0" cellspacing="1" cellpadding="2">
<tr bgcolor="#c7c7c7">
<td width="160" align="center" class="reg_font">Nom</td>
<td width="180" align="center" class="reg_font">Courriel</td>
<td width="110" align="center" class="reg_font">Téléphone</td>
</tr>
<?php
include "connection.php";
$query = "select * from contacts where id != '3' order by lname";
$Statement = mysql_query($query);
while($myid = mysql_fetch_array($Statement)) {
$the_id = $myid["id"];
$last_name = $myid["lname"];
$first_name = $myid["fname"];
$email = $myid["e_address"];
$phonenum = $myid["phone"];
if($bg == "#ededf7"){
$bg = "#e7e7e7";
}else{
$bg = "#ededf7";
}
if(empty($phonenum)){
$phonenum = " ";
}
echo "<tr bgcolor=\"".$bg."\">\n";
echo "<td class=\"reg_font\">".$last_name.", ".$first_name."</td>\n";
echo "<td class=\"reg_font\"><a href=\"mailto:".$email."\" class=\"link_font\">".$email."</a></td>\n";
echo "<td class=\"reg_font\">".$phonenum."</td>\n";
echo "<tr>\n";
}
?>
</table>
Re: I've done the searching
You nailed it. By removing $db-> and replacing with mysql_query all problems were resolved. Thanks!
Re: I've done the searching