PHP -
Ghazal - 23.08.2014
Hello there,
I have got a question .. Which i don't know if i am allowed to post it here or no, anyways i will give it a try.
I am a newbie in PHP.
I was wondering if there is tutorials like showing ban list from mysql using php or an exmaple for it?
Thanks for reading ...
Re: PHP -
Kyle - 23.08.2014
http://www.w3schools.com/sql/sql_select.asp
http://php.net/manual/en/function.mysql-fetch-array.php
Re: PHP -
Ghazal - 23.08.2014
Quote:
Originally Posted by KyleSmith
|
I would like an example script, so i can understand.
Re: PHP -
Kyle - 23.08.2014
Quote:
Originally Posted by Maro06
I would like an example script, so i can understand.
|
The examples are in both pages. Just adapt it to your database structure.
Basically, you're asking for an 'example script' so you don't have to do anything and just copy that one.
Re: PHP -
Ghazal - 23.08.2014
Quote:
Originally Posted by KyleSmith
The examples are in both pages. Just adapt it to your database structure.
Basically, you're asking for an 'example script' so you don't have to do anything and just copy that one.
|
lol.
Actually, how can i even understand from that 2 pages? And i am not going to copy, I will make one by my self, if you don't want to help just dont reply.
Re: PHP -
Kyle - 23.08.2014
Код:
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
printf ("ID: %s Name: %s", $row[0], $row["name"]);
}
mysql_free_result($result);
?>
Re: PHP -
TakeiT - 23.08.2014
You should use Mysqli, not mysql. Mysql is depreciated.
Re: PHP -
iFarbod - 23.08.2014
Use PDO, Or MySQLi
Re: PHP -
Kyle - 23.08.2014
Quote:
Originally Posted by TakeiT
You should use Mysqli, not mysql. Mysql is depreciated.
|
Quote:
Originally Posted by iFarbod
Use PDO, Or MySQLi
|
Код:
<?php
$con = new mysqli("localhost", "mysql_user", "mysql_password");
if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); }
if($result = mysqli_query($con, "SELECT id, name FROM mytable"))
{
while ($row = mysqli_fetch_assoc($result)) {
printf ("ID: %s Name: %s", $row["id"], $row["name"]);
}
mysqli_free_result($result);
}
mysqli_close($con);
?>
Re: PHP -
KingHual - 23.08.2014
Quote:
Originally Posted by KyleSmith
|
Using mysql_* is bad practice as it's not safe, though. They should either use mysqli_* or PDO.