khaki monster

msg:1312634 | 2:42 pm on Feb 25, 2006 (gmt 0) |
are you talking about html table?
|
jatar_k

msg:1312635 | 3:16 pm on Feb 25, 2006 (gmt 0) |
Welcome to WebmasterWorld rscrsc, as far as outputting column names, since they are always the same you could just hard code them and add them to the echo line. You could also use a foreach loop to output them foreach ($line as $key $value) { echo $key . ' : ' . $value . "\t"; } but hardcoding the names might be simpler as for how to then connect to a second db on the same machine. Since the $connection var is still good you just could issue another mysql_select_db call and then issue your query again and parse through your results.
|
SeanW

msg:1312636 | 3:42 pm on Feb 25, 2006 (gmt 0) |
For multiple dbs, fully qualify your select statement: SELECT * from db2.table; You should be able to join between dbs too SELECT * FROM db2.table AS t2, db1.table AS t1 WHERE t1.id = t2.id and so forth. Sean
|
rscrsc

msg:1312637 | 8:38 pm on Feb 26, 2006 (gmt 0) |
I am having a little problem trying to get this statement to work. I am sure its because I am doing something wrong. where am I supposed to add this in my statement. Am I supposed to remove any line before adding this? foreach ($line as $key $value) { echo $key . ' : ' . $value . "\t"; } I have tried adding it after the my last line of code and I have also tried removing my echo statements and adding the lines above. But when I add the lines above I stop getting results. thanks again for help!
|
jatar_k

msg:1312638 | 8:58 pm on Feb 26, 2006 (gmt 0) |
it replaces this line echo $line[0]."\t".$line[1]."\t".$line[2]."t".$line[3]."t".$line[4]."<br>"; like this while ($line = mysql_fetch_row($result) ) { foreach ($line as $key $value) { echo $key . ' : ' . $value . "\t"; } and then whatever comes after that would follow inside your while loop
|
rscrsc

msg:1312639 | 12:03 am on Feb 27, 2006 (gmt 0) |
Thanks for the reply. This is how my code currently looks like. I have made the changes like you suggested, but the problem is when I try to run the same search that I ran before I just get a blank screen with no results. Any ideas or advice as to what else could be wrong. thanks again for all your help! <? $host = "localhost"; $user = "snort"; $pass = "snort"; $dbname = "snort"; $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>"); mysql_select_db($dbname); // This command will perform the query $query= "select * from signature where sig_name= '" . $_POST['IP'] . "'"; //this will try to spit out the previous sql query $result = mysql_query($query) or die('Query failed: ' . mysql_error()); //this is a line break before the spit output while ($line = mysql_fetch_row($result) ) { foreach ($line as $key $value) { echo $key . ' : ' . $value . "\t"; } ?>
|
jatar_k

msg:1312640 | 3:17 am on Feb 27, 2006 (gmt 0) |
I have had that problem before with hosts, was an untrapped error, for some reason error reporting was turned off. dumb have you seen parse errors before with your site (just in case it is the same thing)? maybe I am totally losing it and my code doesn't work at all. The other thing you could do is use an html table to output your results and put your column headings hard coded right in
|
rscrsc

msg:1312641 | 5:19 am on Feb 27, 2006 (gmt 0) |
Yeah in the past when I have had a code error it told me what it was. Does anyone else have any ideas? What I am trying to is have the colums names automatically printed after the query runs. for example if I type in 192.168.1.1 it should display this time ipaddress sig_id date 4.30 192.168.1.1 test_sig 4/4/2004 Currenly with the code I have i get the following 4.30 192.168.1.1 test_sig 4/4/2004 thanks again for the help. I would really like to not use html code if possible to print the tables. Any further help would be very much appreciated as is all the help that everyone have alreay supplied. thanks again!
|
|