Jump to content

krkec

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by krkec

  1. I study ajax as you suggested and come up with this code, but it still wont work. Please help me figure out why it wont work??? in main page i put this: <script> function showData(godina, mjesec, dan) { showdiv(); /*if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } */ if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("ispis").innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST","analiza.php",true); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlhttp.send("god =" + godina + "mj =" mjesec + "d =" + dan); } </script> and i call JS function by this: $calendar.= '<td onclick= showData('.$year.','.$month.','.$list_day.'); class="calendar-day_used">'.$list_day.'</td>'; in analiza.php I put: <?php if (array_key_exists('god', $_POST) && array_key_exists('mj', $_POST)) { //xmlhttp.send("god =" + godina + "mj =" mjesec + "d =" + dan); $godina = $_POST['god']; $godina = $_POST['mj']; $dan = = $_POST['d']; //$mjesec = ($_POST['bar']); // do stuff with params $calendar = '<table cellpadding="0" cellspacing="0" class="calendar">'; $sql="SELECT * FROM `record` WHERE (`Datum` = '" . $godina . "-" . $mjesec . "-" . $dan. "')"; $result=mysql_query($sql); // Mysql_num_row is counting table row $row = mysql_fetch_array($result, MYSQL_BOTH); $polje = explode("-", $row["Datum"]); $calendar = 'Ime i prezime: '.$row["ime"].'<br>'. 'Datum dolaska je: ' . $row["Datum"].'<br>'. 'Datum dolaska je: ' . $polje[0] . '-' . $polje[1] . '-' . $polje[2]+$row["3"].'<br>'. 'Broj noćenja je: ' . $row["4"].'<br>'. $calendar = '<\table>'; echo $calendar; } else { echo 'Invalid parameters!'; } ?>
  2. what I really want to do is when user click on cell of table (calendar date) I want to show information about that date. Could you give mi some example?
  3. Hi I created php function that creates table. I want to create onclick evant on <td> that calls php function showinfo($year,$month,$day). Variable $list_day is inserted when table is generated(local variable for function). Variables $year,$month are global variables. This is how I created <td>: $calendar.= '<td onclick=showinfo($year,$month,'.$list_day.'); class="calendar-day_used">'.$list_day.'</td>'; This is what is generated from above code: <td onclick="showinfo($year," $month,="" 21);="" class="calendar-day_used2">21</td> What am I doing wrong??? Thanks in anvance
  4. Hi I am trying to connect to mysql database and retreve one number. Database has this columns: ID(int), Datum(date), KID(int). <!DOCTYPE html> <html> <head> <link type='text/css' rel='stylesheet' href='style.css'/> <title>PHP!</title> </head> <body> <?php $month = 11; $year = 2013; $list_day = 1; $mysqli= new mysqli("localhost","root","m62rm8F4","test"); if (mysqli_connect_errno($mysqli)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); exit(); } $query = "SELECT `KID` FROM `upis` WHERE (`Datum` = '" . $year . "-" . $month . "-" . $list_day. "')"; $res = $mysqli->query($query); $row = $res->fetch_array(MYSQLI_NUM); $intnum = $row[0]; echo $intnum; ?> </body> </html> I only get on screen: query($query); $row = $res->fetch_array(MYSQLI_NUM); $intnum = $row[0]; echo $intnum; ?> Please help! What am i doing wrong?
×
×
  • 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.