Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])){
- if(isset($_GET['go'])){
- if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){
- $name=$_POST['name'];
- //connect to the database
- $db=mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
- //-select the database to use
- $mydb=mysql_select_db("db427107316");
- //-query the database table
- $sql="SELECT ID, date, domain, links, alexa FROM alexa WHERE domain LIKE '%" . $name . "%' OR links LIKE '%" . $name ."%'";
- //-run the query against the mysql query function
- $result=mysql_query($sql);
- {
- 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>';
- //-create while loop and loop through result set
- while($row=mysql_fetch_array($result)){
- $domain =$row['domain'];
- $links=$row['links'];
- $alexa=$row['alexa'];
- $date=$row['date'];
- $ID=$row['ID'];
- //-display the result of the array
- echo "<tr><td><center>" .$date . "<center></td><td> " .$domain . "</td><td align=right>" . $alexa . " </td><td align=right>" . $links . " </td></tr>";
- }
- echo "</table>";
- }
- }}
- else{
- echo "<p>Please enter a search query</p>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment