I think I clearly specified everything in the other thread. If not, tell me exactly what you'd like to see.
bbcompent1
Ok, what you'll want to do is in your database look for the userid that entered those entries and in your query, specify that you only update the ones that belong to that user. Post your table design and query if you need help with it.
I don't think you understood or maybe I explained it wrong. I have the user specified. What goes wrong is for example I have name, address and town, and let's say the user wants to change only the town but if he left the name and address blank when updating,
it deletes that data form the database, and there is no more name and address specified.
bbcompent1
My best guess at this point would be change:
<h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
to:
<h3>Change to <a href="../Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
or put the full opening URL in where the .. is
And again the problem is not there but in paging. What I'd like to do is have only 10 results. That's how I tried to do it, but it doesn't work:
@{
Layout = "~/Shared/_SiteLayout.cshtml";
var db = Database.Open("StarterSite");
var category = UrlData[0];
Page.Title = "Posted jobs in category: " + category;
var pageSize = 3;
var totalPages = 0;
var count = 0;
var page = UrlData[1].IsInt() ? UrlData[1].AsInt() : 1;
var offset = (page -1) * pageSize;
var sql = "Select Count(*) From PostedJobs";
count = (int)db.QueryValue(sql);
totalPages = count/pageSize;
if(count % pageSize > 0){
totalPages += 1;
}
sql = "SELECT * FROM PostedJobs WHERE Category = @0" +
"Order By PostedDate OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY;";
var data = db.Query(sql, offset, pageSize, category);
<h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3>
foreach (var row in data)
{
<div id="postedjobs">
<ul>
<li>
<h3><a href="/Job/@row.JobID">@row.JobTitle</a></h3>
<p><b>Posted:</b> @row.PostedDate</p>
<p><b>Location:</b> @row.Location</p>
<p><b>Details:</b><br />@row.JobDescription</p>
<p><b>By: @row.UserId</b></p>
</li>
</ul>
</div>
}
<div> <p>Page @page of @totalPages
<center>
@for (var i = 1; i < totalPages + 1; i++){
<a href="/Categories/Jobs/@category/Page/@i">@i</a>
}
</center></p></div>
}
Kaizub
Member
77 Points
42 Posts
Re: Finishing off the website
Feb 26, 2012 01:20 PM|LINK
I think I clearly specified everything in the other thread. If not, tell me exactly what you'd like to see.
I don't think you understood or maybe I explained it wrong. I have the user specified. What goes wrong is for example I have name, address and town, and let's say the user wants to change only the town but if he left the name and address blank when updating, it deletes that data form the database, and there is no more name and address specified.
And again the problem is not there but in paging. What I'd like to do is have only 10 results. That's how I tried to do it, but it doesn't work:
@{ Layout = "~/Shared/_SiteLayout.cshtml"; var db = Database.Open("StarterSite"); var category = UrlData[0]; Page.Title = "Posted jobs in category: " + category; var pageSize = 3; var totalPages = 0; var count = 0; var page = UrlData[1].IsInt() ? UrlData[1].AsInt() : 1; var offset = (page -1) * pageSize; var sql = "Select Count(*) From PostedJobs"; count = (int)db.QueryValue(sql); totalPages = count/pageSize; if(count % pageSize > 0){ totalPages += 1; } sql = "SELECT * FROM PostedJobs WHERE Category = @0" + "Order By PostedDate OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY;"; var data = db.Query(sql, offset, pageSize, category); <h3>Change to <a href="/Categories/Tradesmen/@category">tradesmen</a> in this category.</h3> foreach (var row in data) { <div id="postedjobs"> <ul> <li> <h3><a href="/Job/@row.JobID">@row.JobTitle</a></h3> <p><b>Posted:</b> @row.PostedDate</p> <p><b>Location:</b> @row.Location</p> <p><b>Details:</b><br />@row.JobDescription</p> <p><b>By: @row.UserId</b></p> </li> </ul> </div> } <div> <p>Page @page of @totalPages <center> @for (var i = 1; i < totalPages + 1; i++){ <a href="/Categories/Jobs/@category/Page/@i">@i</a> } </center></p></div> }But thanks for number 2 which I resolved :)