0 Members and 1 Guest are viewing this topic.
//connect to database$mysqli = new mysqli("localhost", "username", "password", "database");//check for errorsif ($mysqli->connect_errno) { echo "Failed to connect to MySQL: " . $mysqli->connect_error;}//write query$res = $mysqli->query("SELECT * from tablename");//fetch query$row = $res->fetch_assoc();//display resultsecho $row['table_id'];
//Connect to the database$con=mysqli_connect("localhost", username", "password", "database") or die(mysqli_connect_error());//Write query$query="SELECT * from tablename";//Fetch results$result=mysqli_query($con, $query);//Display resultswhile($row=mysqli_fetch_array($result)){//use row to fetch the element of each column}//close connectionmysqli_close($con);
//connect to database$con = mysql_connect("localhost", "username", "password");// select database//$db= mysql_select_db("database") or die(mysql_error());//Write query$query= "SELECT* from tablename";//Fetch Results$result=mysql_query($query);//Display resultwhile($row=mysql_fetch_array($result)){// acccess the table elements and display it}//mysql close connectionmysql_close($con);