Page 1 of 1

Help please. Database query

Posted: Mon Jan 05, 2004 3:10 pm
by smoky989
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))&#123;
	$name = $myrow&#1111;"roster.w_name"]; 
	$show = $myrow&#1111;"master_roster.show"]; 
	$active = $myrow&#1111;"master_roster.active"]; 
	$notes = $myrow&#1111;"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>";
	
	&#125;;
	
	echo "</table>"
	?>

Re: Help please. Database query

Posted: Mon Jan 05, 2004 3:14 pm
by poeta_eletrico
well ::::


can u paste here the error message?


poeta_eletrico

I dont get one

Posted: Mon Jan 05, 2004 3:19 pm
by smoky989
I dont get an error message. The script runs and a table is created with nothing in it.

Posted: Mon Jan 05, 2004 3:38 pm
by redmonkey
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.

Posted: Mon Jan 05, 2004 4:04 pm
by smoky989
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.

ALL SET

Posted: Mon Jan 05, 2004 4:58 pm
by smoky989
I got it working from a combination of suggestions. Thanks everyone.