ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ok below i have the following php code
im trying to match up to tables so i get a better and more descriptive output
rg instead of and number "80" i want to output " port http-web"
i thought i had it with the mysql statement below
but ouputs are wrong like they dont match at all
Domain Name Server 69
Domain Name Server 53
PHP Code:
$sql2=( "SELECT services.description FROM services,udphdr WHERE services.port = udphdr.udp_dport"); $result2 = mysql_query($sql2) or die(mysql_error()); $myrow2 = mysql_fetch_array($result2);
The results of the queries have no 'link' between them and the three results are correct, but they can go in any order. I think there can be only one SELECT used, but I don't understand the meaning fully so I don't know how to write it. COuld you explain what you'd like to get exactly (what should be the connections between results of the three queries)?
well one of the statements just outputs all info from a database while the other 2 are doing the same thing as each other.
i want to match up data in the udphdr table with the services table (both in the same database)
instead of getting an output of lets say 80 i want to take that 80 and match it up with what the services tables says what 80 represents via the field description
i kinda know why i have to only use one select statement thought by doing it this way would work too but how do i go about using one select statement
i think if i do some kind of order in them i might be able to match and link them up what do ye think!?
SELECT udphdr.cid, udphdr.sid, udphdr.udp_sport, udphdr.udp_dport,
udphdr.udp_len, udphdr.udp_csum sdesc.description, sdest.description
FROM udphdr, description AS sdesc, description AS sdest
WHERE sdesc.port=udphdr.udp_sport AND sdest.port=udphdr.udp_dport
Not tested, you should check if mysql allows you to run such a query, but I don't see any reason it shouldn't.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.