Jump to content

lak

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lak's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. In MySQL this would read as SELECT * FROM querydate WHERE dateposted >= ( SELECT SUBDATE( CURRENT_DATE, INTERVAL 14 DAY ) AS LASTDATE ) AND dateposted <= CURRENT_DATE Returning records that are NOT more than 14 days from current date so if i do this in CI2 $lastdate=$this->db->query(SELECT SUBDATE( CURRENT_DATE, INTERVAL 14 DAY ) AS LASTDATE ); $currdate=$this->db->query(SELECT CURRENT_DATE AS CURRDATE); $this->db->select(); $this->db->get(querydate); $this->db->where('dateposted=>',$lastdate); $this->db->where('dateposted<=',$currdate); Any MASTER JEDI who can confirm that this absolutely theoritically CORRECT? Many thanks.
  2. To all, OMG, Sorry Sorry Sorry I just read my post after waking up, its horrible wht I have posted last, as I was in state of sleep looking for a quick fix, hence I did nt want to read that article in whole and let that make me go early to sleep. I do respect the fact it requires patience and time, but I am in a worse pit of snake problems which i do nt want to go into personal details. Should have paid more attention to the error I guess i was doing c+v in dreamland: It should read as: $sql="SELECT attrb1 FROM table1"; //attrib1 coltype is int $sql2="SELECT attrib2 FROM table2 WHERE attrib3=".$sql['attrb1'].; @phporcaffeine: thank you and sorry @mdjamato: yes the first query returns multiple queries. Secondly, no error msgs shown, simply a blank pg. @Adam: i was looking for a quick fix, thru Ctrl+F. Well with much reluctance I think i may hv to paste the code. here it is now: //Prepare SQL Statement queryset $sqlQuestion="SELECT questionid, questiontext FROM questions"; $resultQuestion = mysql_query($sqlQuestion); // Write out the HTML for the page ?> <html> <body> <form method="POST" action="process.php"> <!-- Write out the question Text --> <table border="1" cellpadding="6"> <?php while($row = mysql_fetch_array($resultQuestion )) { echo "<tr>"; echo "<td width=525>" . $row['questiontext'] . "</td>"; echo "Hello"; //Prepare statement to fetch options for each question as a queryset $sqlOptions="SELECT options.optionid,options.optiontext,options.optionvalue FROM options,questions WHERE options.questionid=".$row['questionid']. ; //<------The error is here $resultOption = mysql_query($sqlOptions); /*while($col = mysql_fetch_array($resultOption)) { if($row['questionid']==1) { echo "<td> <input name= " .$row['questionid']. " type=radio value=1/>" .$col[optiontext]. "</td>"; echo "<td> <input name= " .$row['questionid']. " type=radio value=0/>" .$col[optiontext]. "</td>"; } else { echo "<td> <input name= " .$row['questionid']. " type=radio value=1/>" .$col[optiontext]. "</td>"; echo "<td> <input name= " .$row['questionid']. " type=radio value=0/>" .$col[optiontext]. "</td>"; } }*/ echo "</tr>"; } ?>
  3. The reason for 2 sql stmts is to allow the page to behave dynamically in creating the table. Ok i give up i tried every possible way now Is it: $sql2="SELECT attrb2 fromt table2 where attrb3=.$sql['attrb1']."; $sql2="SELECT attrb2 fromt table2 where attrb3=".$sql[attrb1].; Can u please give me the correct syntax please? I read the doc in 5 secs there was nothing of this sort where i can append the attribute of the first sql queryset. I guess no 1 has tried this ever b4!!!
  4. Hold on will let u know if it works out fine.
  5. Hi ppl, I have problem in preparing the sql statement which requires attribrute from another sql statement. This is the scenario as in PHP code. $sql1="SELECT attrb1 from table1"; $sql2="SELECT attrb2 fromt table2 where attrb3=".$sql['attrb1']"; What and where is the correct placement of these s'quotes or d'quotes should be? Please help. Thank you.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.