PHP: simple MySQL database query, form and button

Getting started with databases in PHP can seem daunting if you’re trying to eat an elephant right off the bat and making queries that are overly complex. Let’s start with the most basic simple database query to understand the general principle. A working code that can be copied is at the end of the post.

1) output and print one value from the MySQL database in PHP, in our example we will extract the name of the seventh player;
2) make a form on the site (drop-down list) with a button to send the selected value from the form to the program and get the necessary data from the MySQL database.

Continue reading

Posted in PHP | Tagged , , , | Leave a comment

C language: implicit type conversion examples

One of the most hardcore stuff in C lang is implicit type conversion. If you don’t watch for it – you will be in biiig trouble. Take a look at this code:

#include <stdio.h>

int main (void)

//by default 'int' is signed
int foo = -100;

printf ("int foo = %d; unsigned int foo = %u\n", foo, foo);

// lets take unsigned int
unsigned int bar = 10U;

// when we have addition of singned and unsigned variables,
// C transfer signed to unsigned by default
long long int qux = foo + bar;

// so -100 + 10 will become:
printf ("bar + foo = %lld\n", qux);

/* Another case: */

char fred = 'Я';  // char is !signed! integer by default
printf ("<Я> char as an integer = %d\n", fred);

int baz = (int)fred * 2;

printf("<Я> * 2 = %d\n", baz);



Posted in C lang | Leave a comment