-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfollowing.aspx.cs
54 lines (53 loc) · 2.32 KB
/
following.aspx.cs
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
using MySqlConnector;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace RecipeSharing
{
public partial class following : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["id"] != null)
{
using (MySqlConnection connection = new MySqlConnection(@"server=localhost;userid=root;password=;database=recipes"))
{
connection.Open();
MySqlCommand command = connection.CreateCommand();
string SQL = "Select Following from users where UserId=" + Session["id"];
command.CommandText = SQL;
MySqlDataReader dr = command.ExecuteReader();
dr.Read();
command = connection.CreateCommand();
SQL = "SELECT UserId,Username,ProfilePhoto FROM users where UserId in ('" + dr["Following"].ToString() + "')";
SQL = SQL.Replace("'", "");
SQL = SQL.Replace(",)", ")");
command.CommandText = SQL;
dr.Close();
dr = command.ExecuteReader();
string followinghtml = "";
while (dr.Read())
{
byte[] bytes = (byte[])dr["ProfilePhoto"];
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
followinghtml = followinghtml + "<button type='submit' formaction='othersProfile.aspx?id=" + dr["UserId"] + "'>" +
"<div class='col-sm-1'><img src = '" + "data:image/png;base64," + base64String + "' class='profileImg' alt='Image'></div>" +
"<div class='col-sm-9'><br><h4>"+dr["Username"]+"</h4></div>" +
"</button><br>";
}
followings.InnerHtml = followinghtml;
dr.Close();
connection.Close();
}
}
else
{
Response.Write("<script>Alert('Sorry But not logged In!!');</script>");
Response.Redirect("login.aspx");
}
}
}
}