I have a database that has two fields: current and previous
here is the code:
& lt;? $ Username = "*****"; $ Password = "*****"; $ Database = "******"; Mysql_connect (localhost, $ username, $ password) or die ("unable to connect to server"); Mysql_select_db ($ database) or die ("unable to select database"); $ Query = 'SELECT * functions where current = 1 or previous = 1'; $ Result = mysql_query ($ query); $ Num = mysql_num_rows ($ result); Mysql_close (); ? & Gt;
Then output it and manipulate it like this:
& lt; Div class = "tasklist" & gt; & Lt; Div class = "currentProject" & gt; Current project: & lt; / Div & gt; By & lt;? $ I = =; While ($ i & lt; $ num) {$ title = mysql_result ($ result, $ i, "title"); $ Link = mysql_result ($ result, $ i, "weblink"); $ Description = mysql_result ($ result, $ i, "description"); $ Id = mysql_result ($ result, $ i, "id"); $ Howto = mysql_result ($ result, $ i, "howto"); $ Blogpost = mysql_result ($ result, $ i, "blog post"); $ Done = mysql_result ($ result, $ i, "done"); $ Current = mysql_result ($ result, $ i, "current"); $ Previous = mysql_result ($ result, $ i, "last"); If ($ current == 1) {$ current = "current"; } And {$ current = ""; } If ($ east == 1) {$ previous = "previous"; } And {$ previous = ""; }? & Gt; & Lt; Div class = "& lt;? Echo $ done? & Gt; work & quot; echo $ id? & Gt;" Id = "& lt;? Echo $ current. $ Last?" & Gt; & Lt; Div class = "titleWrapper" & gt; & Lt; Div class = "title" & gt; & Lt; A class = "article" href = "& lt;? Echo $ link?" & Gt; & Lt;? Aicho $ title? & Gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; BR & gt; By & lt;? $ I ++; } Echo ""; ? & Gt;
The problem is that since the database is already coming to the present, then it is already running.
Question:
How can I ensure the output current
before and then previous
?
Just add it on the basis of your query previous
.
previous = 0
in the current task registry and previous = 1
Comments
Post a Comment