Monday, June 2, 2008

Can someone write me a php script that takes information from a database table (1 table) and only 1 field from that table (I am using mySQL) and puts the information in a drop down box. Furthermore can you also write me a script that once you log out of the website you can t go back but have to log in again?
Hopefully someone is very helpful. Thank you.

Question #1:
What is the purpose of putting "@" sign in front of global mysql connection?

For example- according to this website- http://www.sitepoint.com/article/users-php-sessions-mysql/3 they use "@mysql_connect" and "@mysql_select_db" instead of simply "mysql_connect" and "mysql_select_db". .


Question #2.
And according to this website: http://www.designplace.org/scripts.php?page=1&c_id=25- they put "$var = @$_GET[ q ] ;". Again- why did they add that "@" asperand sign?


Question #3:
What is the most ideal way to get table results from mysql database?
Right now- I use this code- but I don t think it is universally right because it doesnt work on some servers.

$con = mysql_connect("localhost"-"username"-"password");
mysql_select_db("database_name"-$con);
$result = mysql_query("SELECT * FROM table_name");
echo "<table>"
while($row = mysql_query($result)){
echo "<tr><td>".$row[ column1 ]."</td><td>".$row[ column2 ]."</td></tr>";
}
echo "</table>";

I know it is a lot to ask. :(

i am developing a database that has articles in english and foreign languages- but non-english characters appear as ????? in database. What can i do?
Colanth thanks a lot- would you be kind enough to remind me of the forum s address? thanks a lot.

Hi all. I m looking at creating a PTC website using script from www.yourownbux.com. My question is- does my webserver need to be able to run mysql in order to host this. Obviously this is a question for anyone who has set up a PTC website themselves with the same script.

i have 2 tables in my MySQL. "groups" and "subgroups". like this:

- groups:
id
name

- subgroups
id
name
group

what i want is to print on the page all the groups and it s subgroups. this way:

$conn = db_connect();
$r = $conn->query("SELECT * FROM groups g INNER JOIN subgroups sb ON g.id = sb.group ORDER BY g.id");
if(!$r) throw new Exception( problems with query... );

$context .= <table width="150" border="1"> ;

while($row = $r->fetch_assoc())
{
$context .= "<tr><td>$row[subname]</td></tr>";
}
$context .= </table> ;

this prints out only all subgroups. i simply can t figure out how to print out all the groups too. structure of the database is this:

- groups:
id | name
1 | Group one
2 | Group two

- subgroups: (all of these subs belong to groups 1 & 2)
id | name | group
1 | Subone | 1
2 | Subtwo | 1
3 | Subthree | 1
4 | and again | 2
5 | and more | 2
6 | and last | 2

so what i want to see on the page is simple all groups and subs

get as in echo the contents. with php.
well- figured that out w/o help of anyone here- is there a way to delete sql data from php?

No comments: