PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
smoky989
Forum Commoner
Posts: 41 Joined: Mon Sep 02, 2002 1:14 pm
Post
by smoky989 » Mon Jan 05, 2004 3:10 pm
This has been bugging me for a while now, I know its something small but I can't find it. Assuming all my tabel names and column names are spelled right, shich I've double checked, does anyone see a reason this wouldn't work
Code: Select all
<?php
$db = mysql_connect("localhost", "username", "pass");
mysql_select_db ("db");
$result = mysql_query("select roster.w_name, master_roster.w_name, master_roster.show, master_roster.active, master_roster.notes
from roster, master_roster
where roster.w_name = master_roster.w_name and roster.status = 1 || roster.status = 3
order by master_roster.w_name", $db) or die(MySQL_Error());
echo "<table border =2><tr><td colspan=4><b><div align=center>Testing</div></b></td></tr>";
while($myrow = mysql_fetch_array($result)){
$name = $myrowї"roster.w_name"];
$show = $myrowї"master_roster.show"];
$active = $myrowї"master_roster.active"];
$notes = $myrowї"master_roster.notes"];
echo "<tr><td width=175>";
echo "$name";
echo "</td><td>";
echo "$show";
echo "</td><td>";
echo "$active";
echo "</td><td>";
echo "$notes";
echo "</td><tr>";
};
echo "</table>"
?>
poeta_eletrico
Forum Commoner
Posts: 32 Joined: Mon Dec 22, 2003 7:33 am
Contact:
Post
by poeta_eletrico » Mon Jan 05, 2004 3:14 pm
well ::::
can u paste here the error message?
poeta_eletrico
smoky989
Forum Commoner
Posts: 41 Joined: Mon Sep 02, 2002 1:14 pm
Post
by smoky989 » Mon Jan 05, 2004 3:19 pm
I dont get an error message. The script runs and a table is created with nothing in it.
redmonkey
Forum Regular
Posts: 836 Joined: Thu Dec 18, 2003 3:58 pm
Post
by redmonkey » Mon Jan 05, 2004 3:38 pm
The array keys of $myrow will not include the table names
e.g.
$name = $myrow["roster.w_name"];
$show = $myrow["master_roster.show"];
$active = $myrow["master_roster.active"];
$notes = $myrow["master_roster.notes"];
will be....
$name = $myrow["w_name"];
$show = $myrow["show"];
$active = $myrow["active"];
$notes = $myrow["notes"];
As you are selecting both roster.w_name & master_roster.w_name you will have two w_name columns in the results.
smoky989
Forum Commoner
Posts: 41 Joined: Mon Sep 02, 2002 1:14 pm
Post
by smoky989 » Mon Jan 05, 2004 4:04 pm
ok that got me started. I changed one of the column names from w_name to w_name2 and I get a result now. The only problem is I'm getting each set of info 7 times. Any ideas?
go to
http://striketowers.com/master_roster.php if you want to see what I mean.
smoky989
Forum Commoner
Posts: 41 Joined: Mon Sep 02, 2002 1:14 pm
Post
by smoky989 » Mon Jan 05, 2004 4:58 pm
I got it working from a combination of suggestions. Thanks everyone.