Hi, guys. I need some help for this piece of code: //define vars $date = $_POST['date']; $one = $_POST['one']; $two = $_POST['two']; $three = $_POST['three']; $d = date("D"); $aa = time() + (1 * 24 * 60 * 60); $bb = time() + (2 * 24 * 60 * 60); $cc = time() + (3 * 24 * 60 * 60); $dd = time() + (4 * 24 * 60 * 60); $ee = time() + (5 * 24 * 60 * 60); $ff = time() + (6 * 24 * 60 * 60); $gg = time() - (6 * 24 * 60 * 60); $hh = time() - (5 * 24 * 60 * 60); $ii = time() - (4 * 24 * 60 * 60); $jj = time() - (3 * 24 * 60 * 60); $kk = time() - (2 * 24 * 60 * 60); $ll = time() - (1 * 24 * 60 * 60); if ($d=="Mon") { $varone = date('Y-m-d'); $vartwo = date('Y-m-d', $aa); $varthree = date('Y-m-d', $bb); $varfour = date('Y-m-d', $cc); $varfive = date('Y-m-d', $dd); $varsix = date('Y-m-d', $ee); } else { if ($d=="Tue") { $varone = date('Y-m-d', $ll); $vartwo = date('Y-m-d'); $varthree = date('Y-m-d', $aa); $varfour = date('Y-m-d', $bb); $varfive = date('Y-m-d', $cc); $varsix = date('Y-m-d', $dd); } else { if ($d=="Wed") { $varone = date('Y-m-d', $kk); $vartwo = date('Y-m-d', $ll); $varthree = date('Y-m-d'); $varfour = date('Y-m-d', $aa); $varfive = date('Y-m-d', $bb); $varsix = date('Y-m-d', $cc); } else { if ($d=="Thu") { $varone = date('Y-m-d', $jj); $vartwo = date('Y-m-d', $kk); $varthree = date('Y-m-d', $ll); $varfour = date('Y-m-d'); $varfive = date('Y-m-d', $aa); $varsix = date('Y-m-d', $bb); } else { if ($d=="Fri") { $varone = date('Y-m-d', $ii); $vartwo = date('Y-m-d', $jj); $varthree = date('Y-m-d', $kk); $varfour = date('Y-m-d', $ll); $varfive = date('Y-m-d'); $varsix = date('Y-m-d', $aa); } else { if ($d=="Sat") { $varone = date('Y-m-d', $hh); $vartwo = date('Y-m-d', $ii); $varthree = date('Y-m-d', $jj); $varfour = date('Y-m-d', $kk); $varfive = date('Y-m-d', $ll); $varsix = date('Y-m-d'); } else { if ($d=="Sun") { $varone = date('Y-m-d', $gg); $vartwo = date('Y-m-d', $hh); $varthree = date('Y-m-d', $ii); $varfour = date('Y-m-d', $jj); $varfive = date('Y-m-d', $kk); $varsix = date('Y-m-d', $ll); } } } } } } } Here comes the problem: $sql = "SELECT one, two, three, date FROM table WHERE date='$varone'"; $result = mysql_query($sql) or die("Couldn't execute query"); if(mysql_num_rows($result)) { while($row = mysql_fetch_row($result)) { echo("<ul><li>$one</li><li>$two</li><li>$three</li></ul>"); } } else { echo("<p>No results for $varone.</p>"); } If $varone exists the result I get is only HTML code: <ul><li></li><li></li><li></li></ul> if it doesn't: <p>No results for $varone.</p> (the expected one) I'm stuck. Please help!
Perhaps: echo("<ul><li>{$row['one']}</li><li>{$row['two']}</li><li>{$row['three']}</li></ul>"); PHP: ??
I can't see the purpose of this line: if(mysql_num_rows($result)) { Try.. $sql = "SELECT one, two, three, date FROM table WHERE date='$varone'"; $result = mysql_query($sql) or die("Couldn't execute query"); while($row = mysql_fetch_row($result)) { $one = $row['one']; $two = $row['two']; $three = $row['three']; echo '<ul><li>$one</li><li>$two</li><li>$three</li></ul>'; } } else { echo '<p>No results for $varone.</p>'; }
I did COPY / PASTE of this code: $sql = "SELECT one, two, three, date FROM table WHERE date='$varone'"; $result = mysql_query($sql) or die("Couldn't execute query"); while($row = mysql_fetch_row($result)) { $one = $row['one']; $two = $row['two']; $three = $row['three']; echo "<ul><li>$one</li><li>$two</li><li>$three</li></ul>"; } and again - the result is only html ----- if this helps - here is my SQL structure CREATE TABLE `table` ( `id` int(11) NOT NULL auto_increment, `one` varchar(255) NOT NULL default '', `two` varchar(255) NOT NULL default '', `three` varchar(255) NOT NULL, `date` date NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `date` (`date`) )
Thank you, guys. I figure it out (at last) Here it is: $sql = "SELECT one, two, three, date FROM table WHERE date='$varone'"; $result = mysql_query($sql) or die("Couldn't execute query"); while($row = mysql_fetch_array($result)) { $one = $row['one']; $two = $row['two']; $three = $row['three']; echo "<ul><li>$one</li><li>$two</li><li>$three</li></ul>";