
shadd
Members-
Posts
55 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
shadd's Achievements
-
SOLVED IT BY ADDING IF INSEX<>''THEN DO INSERT WITH THE ENUM FIELD ELSE DO INSERT WITHOUT THE ENUM FIELD IN QUERY END IF;
-
what if i need to account for null entries to this field
-
i have this procedure: DELIMITER $$ CREATE PROCEDURE sp_add_user(IN inname text,IN insex tinytext) MODIFIES SQL DATA BEGIN set @newEanswer_sql=CONCAT('INSERT INTO user(fname,sex)values("',inname,'","',insex,'")' ); PREPARE snewEans_insert FROM @newEanswer_sql; EXECUTE snewEans_insert; DEALLOCATE PREPARE snewEans_insert; END$$ DELIMITER ; when i run it like so: call sp_add_user('pierre',''); it gives me the following error: RETURNED_SQLSTATE MESSAGE_TEXT 01000 Data truncated for column 'sex' at row 1 here is table: create table user ( userid int unsigned not null auto_increment, fname text , sex enum('male','female'), Primary key(userd) ); how can i solve this??
-
i have these tables: create table tblQuestions ( QueId varchar(255), instruction text , question text , Primary key(Que_Id) ); create table tblAnswers ( QueAns_Id int unsigned not null auto_increment, Answer text Primary key(QueAns_Id) )ENGINE=InnoDB DEFAULT CHARSET=UTF8; create table tblScore ( Ans_Id varchar(255), QueAns_Id int unsigned not null , User_id int unsigned , Answer_score float not null default 0.0,/*0.0 or 1.0*/ Primary key(Ans_Id,User_id), foreign key(QueAns_Id) references tblAnswers(QueAns_Id) on delete cascade on update cascade, foreign key(User_id) references tblUsers(sUser_id) on delete cascade on update cascade )ENGINE=InnoDB DEFAULT CHARSET=UTF8; create table tblUsers ( sUser_Id mediumint unsigned not null auto_increment, First_name varchar(50) not null, Primary key(sUser_Id), unique key(S_UPassword) )ENGINE=InnoDB DEFAULT CHARSET=UTF8; INSERT INTO tblUsers(First_name) VALUES('Apple); INSERT INTO tblQuestions(QueId,instruction ,question )VALUES('1.1.49','','Hard work may lead to success.(rewrite using:.....could.........)') ('1.1.49','','Hard work may lead to success.(rewrite using:.....could.........)'); ('1.1.50','','Jessy can speak English yet she has never been to school.(Rewrit using:......inspite of ......)'); ('1.1.51',' Read the passage below and then answer in full sentences the questions that follow.','What is the passage about?'); ('1.1.51.10','','why am i not in order?'); ('1.1.51.2','','Why is it iam not in place above 1.1.51.10'); ('1.1.51.3','','Yeah part b,he should be below us!'); iam using the select query below to get the data,but the questions are not in order i like to have: 1.1.49 1.1.50 1.1.51 1.1.51.2 1.1.51.3 1.1.51.10 SELECT q.QueId AS Q_id, CASE when ROUND((LENGTH(q.QueId)-LENGTH(replace(q.QueId,'.',''))) / LENGTH('.') )>2 then concat(q.Que_Id,CHAR(CAST(SUBSTRING_INDEX(q.QueId,'.',-1) AS INTEGER)+96))END as QueNo, CASE when ROUND((LENGTH(q.QueId)-LENGTH(replace(q.QueId,'.',''))) / LENGTH('.') )>2 then CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(q.QueId,'.',-2),'.',1) AS INTEGER) ELSE CAST(SUBSTRING_INDEX(q.QueId,'.',-1) AS INTEGER)end as qNo, q.instruction, q.question, Z.QueAns_Id, Z.Answer, Z.User_id,Z.Answer_score FROM tblQuestions q LEFT JOIN (select B.QueAns_Id, B.Answer, C.Ans_Id,C.User_id,C.Answer_score from tblAnswers B LEFT JOIN tblScore C ON B.QueAns_Id=C.QueAns_Id AND C.User_id=1)AS Z ON q.QueId=Z.Ans_Id and SUBSTRING_INDEX(q.QueId,'.',2)='1.1' order by qNo asc;
-
correct and simple but,is it possible to add a key to the results array like so: foreach ($results as $lvl => $arr) { echo "$lvl <UL>"; foreach ($arr as $sub) { $results['go_to_exam'] ="dear";echo "<li>$sub</li>"; } echo "</ul>"; } in a for loop this could work: for ($i = 0; $i < count($results); $i++) { $results[$i]['go_to_exam'] = "dear".$i; } if i had used fetch:assoc
-
can you please, show your concept on that array using php
-
here is the array that i need to print out in a <ul> : array ( 0 => array ( 'pId' => '1.1', 'Duration' => NULL, 'emdate' => NULL, 'Sub' => 'BASIC lug', 'SubId' => 1, 'Lvl' => ' ULE', 'LvId' => 1, ), 1 => array ( 'pId' => '1.2', 'Duration' => NULL, 'emdate' => NULL, 'Sub' => 'BASIC lug', 'SubId' => 1, 'Lvl' => ' ULE', 'LvId' => 1, ), 2 => array ( 'pId' => '1.3', 'Duration' => NULL, 'emdate' => NULL, 'Sub' => 'ger', 'SubId' => 1, 'Lvl' => ' ACE', 'LvId' => 2, ) ) iam expecting to get this result; ULE BASIC LUG BASIC LUG ACE ger
-
I have this resultset : pId Duration emdate Sub SubId Lvl LvId 1.1 null null basic lug 1 ule 1 1.2 null null basic lug 1 ule 1 1.2 null null ger 2 ace 1 I would like to have it display like so in a <ul>: ULE BASIC LUG BASIC LUG ACE ger how can I achieve that if each is a row from database resultset. I have tried ; foreach($ScheduledExamlist as $Scheduledexam) { echo '<li class="current"><a href="#">'.$Scheduledexam['Lvl'].'</a></li>' ; echo '<li>'.$Scheduledexam.'</li>'; } but heading appears twice
-
won't there be too much overload to the database and effectiveness of performance due to too many calls??
-
thanks for the job butit still resets the timer to 3 seconds on page refresh which is not required.it is supposed to count down continuously
-
180 is 3hours and not 3minutes. And after hard coding the 180 in, the timer does not count down it simply displays for aroun 3 sec and shows expired
-
i have tried this by putting the end time <!DOCTYPE HTML> <html> <body> <p id="demo"></p> <!--button onclick="countdownTimeStart()">Start Timer</button--> <script> // Set the date we're counting down to function strToMins(t) { var s = t.split(":"); return Number(s[0]) * 60 + Number(s[1]); } function countdownTimeStart(){ let currentTime = new Date().getTime(); let countDownTime = new Date(currentTime + 2 * 60 * 60 * 1000); //var countDownTime = strToMins(" 06:45:00"); // Update the count down every 1 second var x = setInterval(function() { // Get todays date and time var now = new Date().getTime(); // Find the distance between now an the count down date var distance = countDownTime - now; // Time calculations for days, hours, minutes and seconds var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); // Output the result in an element with id="demo" document.getElementById("demo").innerHTML = hours + "h " + minutes + "m " + seconds + "s "; // If the count down is over, write some text if (distance < 0) { clearInterval(x); document.getElementById("demo").innerHTML = "EXPIRED"; } }, 1000); } window.onload = function () { //var timeLeft = 3600*1, // display = document.querySelector('#time'); countdownTimeStart() }; </script> </body> </html> but still i get the page refreshing the timer to start
-
an example of this will be great thanks
-
i have this timer: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Countdown</title> <script type="text/javascript"> var hours; var mins var secs; function cd() { // below count down for 2 hours and 10 mins and 10 seconds // Or you could provide a string such as => [var time = "10:10:10";] // And construct a function to fetch values from correct parts hours = 2; mins = 10; secs = 10; progr_ess=130; //document.getElementById("progressBar").setAttribute('max','130'); redo(); } function dis(hours, mins, secs) { var disp; if (hours <= 9) { disp = " 0"; } else { disp = " "; } disp += hours + ":"; if (mins <= 9) { disp += " 0"; } else { disp += " "; } disp += mins + ":"; if (secs <= 9) { disp += "0" + secs; } else { disp += secs; } return (disp); } function redo() { secs--; if (secs == -1) { secs = 59; mins--; document.getElementById("progressBar").value = 130-progr_ess ; progr_ess -= 1; } if (mins == -1) { mins = 59; hours--; } document.getElementById("txt").value = dis(hours, mins, secs); if ((mins == 0) && (secs == 0) && (hours == 0)) { window.alert("Time is up. Press OK to continue."); // window.open("module.aspx", "_parent ") } else { cd = setTimeout("redo()", 1000); } } function init() { cd(); } window.onload = init; </script> <style> #txt { border: none; font-family: verdana; font-size: 16pt; font-weight: bold; border-right-color: #FFFFFF } </style> </head> <body> <form id="form1" > <div> <div> <input id="txt" type="text" value="00:00:00" name="disp" /> </div> <progress value="0" max="130" id="progressBar"></progress> </div> </form> </body> </html> how can i make sure it does not go back to start time duration on page refresh? how can i accustom it to recieve the count down duration using php variable?
-
i have this code: $data={"egg","york","pork"} ; $total=count($data);//$j=0; for ($i = 0; $i < $total; $i++){//$j++; echo 'SECTION '; echo ($j <= 2) ? "A" : "B" ;break; echo $data[$i]; } i would like to print: SECTION A eggg york Section B pork .... how can i do that inside the for loop??How can I do a groupby section ??