-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShowTrendingKeywords.php
85 lines (66 loc) · 2.33 KB
/
ShowTrendingKeywords.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
<<<<<<< HEAD
/***********************************************************************
* ShowTrendingKeywords.php
=======
/**
* Script used for seraching and outputting keywords
>>>>>>> c90a6c3feb477ad2334df22e1462ab875a4ce2ac
* @Author Manzoor Ahmed
**********************************************************************/
require_once 'connection.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);
if(isset($_POST['submit']))
{
$dbc =$GLOBALS['dbc'];
$word = $_POST['search'];
//look in `course_data` table for course name and link
$course = "SELECT * FROM `keywords`
WHERE `title` LIKE '$word%'
OR `short_desc` LIKE '$word%'
OR `link` LIKE '$word%';"
or die($dbc->error);
$run_course = $dbc->query($course) or die ($dbc->error);
if(mysqli_num_rows($run_course) != 0){
while($row = mysqli_fetch_array($run_course)){
$id = $row[0];
$title = $row[1];
$link = $row[2];
$short_desc = $row[3];
$old_hit = $row[4];
echo "<a href='$link' style='color:green;'>$title</a>";
echo "<p>$short_desc</p>";
echo "</b>";
$new_hit = $old_hit +1;
$inc = "UPDATE `keywords`
SET `hits` = '$new_hit'
WHERE `id` = '$id'";
$run = $dbc->query($inc) or die($dbc->error);
}
}
else if(mysqli_num_rows($run_course) == 0) {
$in_course = "SELECT * from `course_data`
WHERE `title` LIKE '$word%'
OR `course_link` LIKE '$word%'
OR `short_desc` LIKE '$word%';"
or die($dbc->error);
$run_in = $dbc->query($in_course) or die ($dbc->error);
while($row1 = mysqli_fetch_array($run_in)){
$title1 = $row1['title'];
$short_desc1 = $row1['short_desc'];
$link1 = $row1['course_link'];
$insert_1 = "INSERT INTO `keywords`
(`id`,`title`,`link`, `short_desc`,`hits`)
VALUES ('','$title1','$link1','$short_desc1','');";
$run_1 = $dbc->query($insert_1) or die($dbc->error);
echo "<a href='$link1' style='color:green;'>$title1</a>";
echo "<p>$short_desc1</p>";
echo "</b>";
}
}else{
echo "NO RESULTS FOR " .$word;
echo "</b>";
}
}
?>