Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1.   $user = "mysqlusername";
  2.   $pass = "fbyqZzyh6FxCtNau";
  3.   $db = "db_name";
  4.  
  5.   $con = mysql_connect("localhost",$user,$pass) or die ("Verbindungsproblem.");
  6.   mysql_select_db($db,$con);
  7.  
  8.   $query = "select title,text from articles where 1=1;";   
  9.     $result = mysql_query($query);
  10.     if($result) {
  11.         echo "<table border=1>";
  12.         while($row=mysql_fetch_row($result))
  13.         {
  14.            
  15.         for($i=0;$i<count($row);$i++){ 
  16.             echo "<tr>\n";
  17.             echo "<td>";
  18.             if($i==0)
  19.                 echo "<h3>";
  20.             echo $row[$i];
  21.             if($i==0)
  22.                 echo "</h3>";
  23.             echo "</td>\n";
  24.             echo "</tr>\n";
  25.         }
  26.        
  27.         }
  28.         echo "</table><br><br>";
  29.     } else {  
  30.         echo "<br>".mysql_errno($con) . ": " . mysql_error($con) . "\n";
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement