rhoula

Untitled

Jan 15th, 2013
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])){
  3. if(isset($_GET['go'])){
  4. if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){
  5. $name=$_POST['name'];
  6.  
  7. //connect to the database
  8. $db=mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
  9.  
  10. //-select the database to use
  11. $mydb=mysql_select_db("db427107316");
  12.  
  13. //-query the database table
  14. $sql="SELECT ID, date, domain, links, alexa FROM alexa WHERE domain LIKE '%" . $name . "%' OR links LIKE '%" . $name ."%'";
  15.  
  16. //-run the query against the mysql query function
  17. $result=mysql_query($sql);
  18. {
  19. echo '<table border=1 width=600><tr><td><b><center>Date</center></b></td><td><b><center>Domain</center></b></td><td><b><center>Alexa</center></b></td><td><b><center>Links<center></b></td></tr>';
  20.  
  21.  
  22. //-create while loop and loop through result set
  23. while($row=mysql_fetch_array($result)){
  24. $domain =$row['domain'];
  25. $links=$row['links'];
  26. $alexa=$row['alexa'];
  27. $date=$row['date'];
  28. $ID=$row['ID'];
  29.  
  30. //-display the result of the array
  31. echo "<tr><td><center>" .$date . "<center></td><td>&nbsp;&nbsp;" .$domain . "</td><td align=right>" . $alexa . "&nbsp;&nbsp;</td><td align=right>" . $links . "&nbsp;&nbsp;</td></tr>";
  32. }
  33. echo "</table>";
  34.  
  35. }
  36. }}
  37. else{
  38. echo "<p>Please enter a search query</p>";
  39. }
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment