Bachu 45 Newbie Poster

Replace your display Function with this code. You missed to put <tr> tag in your table

function display($getallen){
 $table = '<table  border="1px" cellpadding="1px">';
 $bingokaart = array();

 for ($row = 1; $row < 7; ++$row){
     $table .= '<tr>';
     //iets met rijnummer doen en deze printen?
        foreach ($getallen as $number){
        $table .= '<td>'  .$row .  $number .'</td>';
    }
    $table .= '</tr>';
 }

  $table .='</table>'; 
echo $table;  
 }
Bachu 45 Newbie Poster

Try this

Click Here

Bachu 45 Newbie Poster

@fireburner29, You can also redirect it to the same page.

check this session value $_SESSION['sess_userrole'], before you print the details. Means that if its value is admin, print the admin details. Else print
the normal user details.

Bachu 45 Newbie Poster

Check this link Click Here.

Bachu 45 Newbie Poster

Try This Click Here

Bachu 45 Newbie Poster

Try this ..Click Here

And change the click event to mouseover

Bachu 45 Newbie Poster

Did you dry just print the value directly like
<img id="imgs" src="../images/verificarimg/img.jpeg" width=700> ?

Then, If you don't get the image, please check the path of image/name of image/type of image(jpeg,jpg,png etc)

Bachu 45 Newbie Poster

Check this Click Here

Bachu 45 Newbie Poster

Try this

function setMyValue ($myValue) {
$newValue = (int)$myValue;
$myArray = array_reverse(str_split($newValue));
$myValue ="";
foreach ($myArray as $key=>$myDigits) {
    $myValue.=($key>0 && $key%2==0) ? ":" : "";
    $myValue.= $myDigits;
}
return strrev($myValue);
}

echo setMyValue(91819.0);
Bachu 45 Newbie Poster

Try this Click Here

Bachu 45 Newbie Poster

Try this

<?php
$yt_url="http://www.youtube.com/watch?v=ZvzwthHh-IQ";
function get_youtube_id_from_url($url)
    {
        preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $url, $matches);
        return $matches[1];
    }
$variable= get_youtube_id_from_url($yt_url);

echo "<div align='center'><iframe src=\"//www.youtube.com/embed/" . $variable. "\" style=\"background: #fff;\" frameborder=\"0\" height=\"300\" scrolling=\"auto\" width=\"480\"></iframe></div>";
?>
OsaMasw commented: This solved my problem before I asked +2
Bachu 45 Newbie Poster

Change the above code to this

<td><input type="text" name="c1" value=" <?php if($p_id!="")echo $a; else echo $p_name; ?>" ></td>
cwarn23 commented: Great answer +12
Bachu 45 Newbie Poster

Try this

<?php
 //table Name
$tableName = "MyTable";
//database name
$dbName = "MyDatabase";


 $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); 
 mysql_select_db($dbName) or die(mysql_error()); 

//get the first row fields 
$fields = "";
$fieldsInsert = "";
if (($handle = fopen("test.csv", "r")) !== FALSE) {
    if(($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        $fieldsInsert .= '(';
        for ($c=0; $c < $num; $c++) {
            $fieldsInsert .=($c==0) ? '' : ', ';
            $fieldsInsert .="`".$data[$c]."`";
            $fields .="`".$data[$c]."` varchar(500) DEFAULT NULL,";
        }

        $fieldsInsert .= ')';
    }


    //drop table if exist
    if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$tableName."'"))>=1) {
      mysql_query('DROP TABLE IF EXISTS `'.$tableName.'`') or die(mysql_error());
    }

    //create table
    $sql = "CREATE TABLE `".$tableName."` (
              `".$tableName."Id` int(100) unsigned NOT NULL AUTO_INCREMENT,
              ".$fields."
              PRIMARY KEY (`".$tableName."Id`)
            ) ";

    $retval = mysql_query( $sql, $conn );

    if(! $retval )
    {
      die('Could not create table: ' . mysql_error());
    }
    else {
        while(($data = fgetcsv($handle, 1000, ",")) !== FALSE) {

                $num = count($data);
                $fieldsInsertvalues="";
                //get field values of each row
                for ($c=0; $c < $num; $c++) {
                    $fieldsInsertvalues .=($c==0) ? '(' : ', ';
                    $fieldsInsertvalues .="'".$data[$c]."'";
                }
                $fieldsInsertvalues .= ')';
                //insert the values to table
                $sql = "INSERT INTO ".$tableName." ".$fieldsInsert."  VALUES  ".$fieldsInsertvalues;
                mysql_query($sql,$conn);    
        }
        echo 'Table Created';   
    }

    fclose($handle);

}

?>
Bachu 45 Newbie Poster

Do the following changes

<?php
global $con;
require_once("connect.php");
$productValue="";
$productWeight="";
$productCode = "";

if(isset($_POST['button1']))
    {
        // Get values from form 
        $sno =$_POST['txtsno']; 

        $record_check ="SELECT * FROM test WHERE sno = '$sno' ";
        $result=mysqli_query($con, $record_check);
        $row = mysqli_fetch_array($result); 
        if(!$row)
                    die ('No record Found');
        else {
            $productValue = $row['packing'];
            $productWeight = $row['weight'];
            $productCode = $sno;
        }                    
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Display data in textboxes</title>
<style type="text/css">

html {
overflow:auto;
}

body {
background-color:#FFFFFF;
margin:0 auto;
}

#mypopup
{
float: left;
width: 250px; height: 350px;
background: #90bade; 
border: 1px solid #069;
text-align:center;
padding:2px;
margin-top:150px;
margin-left:100px;
overflow:auto;
}

#header
{
background-color:#3399FF;
background-position:left center;
line-height:25px;
font-size:22px;
color:#FFFF33;
font-weight:600;
border-bottom:1px solid #6699CC;
padding:10px;
}
</style>


</head>
<body>
<center>
  <div id="mypopup">
    <div id="header">Search Data</div>
    <div style="margin-top:80px;">

     <form name="form1" action="#" method="post">
        <table border=0; cellpadding="1" cellspacing="1" bgcolor="#CCFFFF" align="center" >
          <tr>
            <td>Code</td>
            <td width="50px"><input type="text" name="txtsno" id="txtsno" value="<?php  echo $productCode ; ?>" title="Enter product code" onkeypress="validate(event)" ;  onfocus="this.select()" /></td>
          </tr>
          <tr>
            <td>Product</td>
            <td><input type="text" name="txtpro" value="<?php echo $productValue; ?>" title="Enter product name" ></td>
          </tr>
          <tr>
            <td>Weight</td>
            <td><input type="text" name="txtwet" value="<?php echo $productWeight; ?>" title="Enter product weight" onfocus="this.select()" ></td>
          </tr>
        </table>
        <div style=text-align:center;margin-top:20px;>
          <input type="submit" name="button1" value="Display" >
          <input type="reset" name="button2" value="Clear" >
        </div>
      </form>
    </div>
  </div>
</center>
<?php 
        mysqli_close($con);
?>
</body>
</html>

And also made changes in connect.php

<?php
// Connection variables
$host="localhost";
$username="root";
$password="";
$db_name="DatabaseName"; 


// Connect to database
$con=mysqli_connect("$host", "$username", "$password", "$db_name");

// Connect result
if(!$con){
die('Error Connecting to …
Bachu 45 Newbie Poster

Try this

$username = (isset($_POST['Username'])) ? $_POST['Username'] : "";
Bachu 45 Newbie Poster

Hai;

You are forgotten to echo the option value.

Please change this

<option value="<?php $x['id']?>" name="<?php $x['id']?>"><?php echo $x['display_name']?></option>

into

<option value="<?php echo $x['id']?>" name="<?php echo $x['id']?>"><?php echo $x['display_name']?></option>

If you want to print this result on same page..
please chage this

<form action="post.php" method="post">

into

<form action="" method="post">
Bachu 45 Newbie Poster

@tqmd1

Please delete previous values from the table .. And test the above code again.

Bachu 45 Newbie Poster

Try this

<?php

    $dates = array("1/28/13","1/29/13","1/30/13","1/31/13");
    foreach($dates as $myDate) {
        $dueDate = date('n/j/y', strtotime("+1 months", strtotime($myDate)));
        $myDateMonth = date ('n',strtotime($myDate));
        $dueDateMonth = date('n', strtotime($dueDate));
        $myDateYear = date ('Y',strtotime($myDate));
        $dueDateYear = date ('Y',strtotime($dueDate));


            if(($dueDateMonth - $myDateMonth)>1) {
                if($myDateYear==$dueDateYear) $nextMonth = $myDateMonth+1;
                else if($myDateYear<$dueDateYear) $nextMonth = 1;
                $dueDateOrg = date("n/t/y", strtotime($nextMonth."/1/".$dueDateYear));
            }
            else {
                $dueDateOrg = $dueDate;
            }



        echo $myDate." due date is ".$dueDateOrg."<br />";
    }

?>
Bachu 45 Newbie Poster

Hai;

You use a hidden field for store this total value in your form.Like

<input type="hidden" name="hdnTotal" id="hdnTotal" value="" />

And also add the below code in your calculateSum().

 $("#hdnTotal").val(sum5.toFixed(2));

In your action page you will get the total value as

  $_POST['hdnTotal'] //if you use post methode
  $_GET['hdnTotal'] // if you user get methode
Bachu 45 Newbie Poster

It is possible, In jquery

exg:

<script type="text/javascript">
$(function(){
<?php
    if($id==1)
    {
?>
        window.location="page1.php";
<?php
    }
    else
    {
?>
        window.location="page2.php";
<?php    
    }
    ?>
});
</script>
Bachu 45 Newbie Poster

By using Jquery , Try this

    $('#CompoBoxId').change(function() {
        alert($(this).val());
    });
Bachu 45 Newbie Poster

When you check login of a user;
set Exp date from reg date like

$expDate = strtotime(date("Y-m-d", strtotime($regDate)) . " +30 days");

Set your select query like

SELECT * FROM UserTableName WHERE ($expDate >= DATE(NOW()))

If this query returns values .. set user is loged in

else redirect to login page

Bachu 45 Newbie Poster
broj1 commented: Very good link +7
diafol commented: Yep, good link x2 +14
Bachu 45 Newbie Poster

Hi, @diafole .Good one.

Only One suggestion

I think, checking with Id is better than checking with name ...

Name Can be repeate ... Is it ?

Bachu 45 Newbie Poster

Try this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Table-Text-Area Exg</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>

<body>
<table id="myTable" width="200px" cellpadding="0px" cellspacing="0px">
  <tr><td><label for="Cname"> No of Partipants:</label></td><td>
 <select style="width:160px;" id="text" name="participants" required="required" > 
            <option id="" value="0" name="">-Select participant-</option>  
                        <option id="1" value="1" name="" >1</option>
                        <option id="" value="2" name="" >2</option>
                        <option id="" value="3" name="">3</option>
                        <option id="" value="4" name="">4</option>
                        <option id="" value="5" name="">5</option>
                        <option id="" value="6" name="">6</option>
                        <option id="" value="7" name="">7</option>
                        <option id="" value="8" name="">8</option>
                        <option id="" value="9" name="">9</option>
                        <option id="" value="10" name="">10</option>
                        <option id="" value="11" name="">11</option>
                        <option id="" value="12" name="">12</option>
                        <option id="" value="13" name="">13</option>
                        <option id="" value="14" name="">14</option>
                        <option id="" value="15" name="">15</option>
                        <option id="" value="16" name="">16</option>
                        <option id="" value="17" name="">17</option>
                        <option id="" value="18" name="">18</option>
                        <option id="" value="19" name="">19</option>
                        <option id="" value="20" name="">20</option>
                        <option id="" value="21" name="">21</option>
                        <option id="" value="22" name="">22</option>
                        <option id="" value="23" name="">23</option>
                        <option id="" value="24" name="">24</option>
                        <option id="" value="25" name="">25</option>
                        <option id="" value="26" name="">26</option>
                        <option id="" value="27" name="">27</option>
                        <option id="" value="28" name="">28</option>
                        <option id="" value="29" name="">29</option>
                        <option id="" value="30" name="">30</option>
                        <option id="" value="31" name="">More</option>
</select>
</td></tr>
</table>

<table id="myFilterTable" width="200px" cellpadding="0px" cellspacing="0px">

</table>

<script type="text/javascript">
$(function(){
    $('#text').change(function(){
        $('#myFilterTable').html('');
        var sltdValue = $(this).val();
        var i;
        for(i=0;i<sltdValue;i++) {
            $('#myFilterTable').append('<tr><td>Participant</td><td><textarea name="txtarea[]"></textarea></td></tr>'); 
        }
    });
});
</script>

</body>
</html>
Bachu 45 Newbie Poster

Pass students id's ,in your form

with

    <input type="checkbox" checked="checked"  name="att[]" value="1"  />
    <input type="hidden" name="stdId[]" value="<?php echo $id; ?>"  />

in attendance.php

<?php
$att = $_POST['att'];
$stdId = $_POST['stdId'];

            foreach($att as $key => $attendance) {
                          $at = $attendance ? 'P' : 'N';

                $query = "INSERT INTO `attendance`(`stud_id`,`att`) VALUES ('".$stdId[$key]."','".$at."') ";
                $result = mysql_query($query);
            }           
?>
havish999 commented: well i tried a different way.. trying with it now.. i will try tour solution also.. but i din't get the idea behind your logic +0
Bachu 45 Newbie Poster

Try this

<?php
$urls="list.txt";
$page = join("",file("$urls"));
$kw = explode("|", $page);
$count=0;
$arrayRow=0;
$links = array();
$images = array();
$widths = array();
$heights = array();

foreach($kw as $key=>$vl) {
    $count++;
    if ($count==1)    $links[$arrayRow] = $vl;

    if ($count==2)     $images[$arrayRow] = $vl;

    if ($count==3)     $widths[$arrayRow] = $vl;

    if ($count==4){
        $heights[$arrayRow] = $vl;
        $count = 0;
        $arrayRow++;
    }
}

?>
Bachu 45 Newbie Poster

First you check, is posted file exist or not

EXg:

$yourFile = "uploads/".$_POST['selectBoxName'];
$checkFile = fopen($yourFile, 'w') or die("can't open file");
fclose($checkFile);

If file exist, then

unlink($yourFile);
Bachu 45 Newbie Poster

First you save the user_id, action_type (IN or OUT) and current_time of user on table.
Then check last action type of that user.
If last action_type is IN , show punch out button, else show punch in button.

Bachu 45 Newbie Poster

Try this

<?php
if (isset($_POST['generator'])) {
$charset = 'absdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ0123456789%$#-()*&.,';
$generated_password = substr (str_shuffle($charset),0, 12);
}
?>
<form action ="" method="post">
<input type="submit" name="generator" value="Generate"><input type="text" value="<?php if (isset($generated_password)) {echo $generated_password; } ?>"/>
</form>
rayidi commented: This will exactly what andyy121 need :) +2
Bachu 45 Newbie Poster

Exg:

In your Form ..

<input type="checkbox" name="chk[]" value="1" />
<input type="checkbox" name="chk[]" value="2" />
<input type="checkbox" name="chk[]" value="3" />

In action page

<?php
if($_POST['chk']) {
$chekedValues=  array();
$chekedValues = $_POST['chk'];
$append="";
foreach ($chekedValues as $key=>$value) {
            $append.=($key==0) ? 'WHERE ' : 'OR';
            $append.= " db_table_field_name="."'".$value."'";
}

$sqlsearch = mysql_query("SELECT * FROM db_table_name ".$append);

    while ($row = mysql_fetch_array($sqlsearch))
        {

        }
}
?>
Bachu 45 Newbie Poster
if($_POST['add_marks'] ==1)
{
include('includes/connect.php');
$bots = array();
$mts = array();
$eots = array();

$bots =$_POST['bot'];
$mts=$_POST['mt'];
$eots=$_POST['eot'];

    foreach($bots as $key=>$bot)
    {
    $insert = "INSERT INTO marks(beginning_of_term,mid_term,end_of_term) VALUES('$bot','$mts[$key]','$eots[$key]')";
    $execute_insert = mysql_query($insert);
    }
}
Bachu 45 Newbie Poster
<?php
$sql=mysql_query("SELECT * FROM `products` where tf=1 and star='7' ORDER BY `id` DESC");
$inc = 0;
while($r=mysql_fetch_array($sql)){
    $inc++;
    $id=$r['id'];
    ?>
<div style="width:152px; height:205px;">

<?php echo $id; ?>
</div>
<?php 
    if($inc%4==0) echo '<hr />';
} 
?>

Here I have seperated each 4 items by hr tag.. This will help you... to know how to
seperte items.

mahdiyazdani commented: Thanks +0
Bachu 45 Newbie Poster

In form

<tr bgcolor="<?php echo $bg; ?>">
                  <td><?php  echo $rows['firstName']." ".$rows['lastName']." ".$rows['otherName'];  ?></td>
                  <td><?php  echo $rows['regNo']; ?></td>
                  <td><?php  echo $rows['class']." ".$rows['stream']; ?></td>
                    <td><div align="center"><input type="text" name="bot[]" size="10" /></div></td>
                  <td><div align="center"><input type="text" name="mt[]" size="10" /></div></td>
                  <td><div align="center"><input type="text" name="eot[]" size="10" />
                  <input type="hidden" value="<?php echo $rows['school_id']; ?>" name="schoolId[]"> 
                  </div></td>
              </tr>

In action page

if($_POST['add_marks'] ==1)
{
include('includes/connect.php');
$bots =$_POST['bot'];
$mts=$_POST['mt'];
$eots=$_POST['eot'];
    foreach($bots as $key=>$bot)
    {
    $insert = "INSERT INTO marks(beginning_of_term,mid_term,end_of_term) VALUES('$bot','$mts[$key]','$eots[$key]')";
    $execute_insert = mysql_query($insert);
    }
}
broj1 commented: Nice and concise +6
Bachu 45 Newbie Poster

In form.php

<html>
<body>

<form action="number.php" method="post">

Enter number: <input type="text" name="number" /><br /><br />

Enter number to Add: <input type="text" name="add" /><br /><br />

Enter number to Subtract: <input type="text" name="subtract" /><br /><br />

Enter number to multiply: <input type="text" name="multiply" /><br /><br />

Enter number to divide: <input type="text" name="divide" /><br /><br />

<input type="submit" value="Submit">

</form>

</body>
</html>

In number.php

<?php
$number = (isset($_POST['number']) && $_POST['number']!="") ? $_POST['number'] : '0';
print "\$number = ".$number.";<br />";
$number += $_POST['add'];
print "\$number += ".$_POST['add'].";<br /> The answer is <b>$number</b>. <br /><br />";

$number -= $_POST['subtract'];
print "\$number -= ".$_POST['subtract'].";<br /> The answer is <b>$number</b>. <br /><br />";

$number *= $_POST['multiply'];
print "\$number *= ".$_POST['multiply'].";<br /> The answer is <b>$number</b>. <br /><br />";

$number/= $_POST['divide'];
print "\$number /= ".$_POST['divide'].";<br /> The answer is <b>$number</b>. <br /><br />";

?>
LastMitch commented: Thanks for the example! +5
Bachu 45 Newbie Poster
<?php
$targetPath = $_SERVER['DOCUMENT_ROOT'].'/upload/';

if (isset($_POST['submit'])){

$filename = basename( $_FILES['file']['name'], ".pdf");

if($_FILES['file']['type']=='application/pdf') {
        $filename = preg_replace("/[^A-Za-z0-9_-]/", "", $filename).".pdf";
        $thumb = basename($filename, ".pdf");
        $cpy=1;
        do {
            $targetFile =  str_replace('//','/',$targetPath) ."Copy".$cpy. $filename;
            $filename="Copy".$cpy. $_FILES['file']['name'];
            $cpy++;
        }while(is_file($targetFile));

            if(move_uploaded_file($_FILES['file']['tmp_name'], $targetPath.$filename)) {             
                    $pdfWithPath = $targetPath.$filename;
                    echo "File Uploaded Successfully";
            }
}
else {
    echo "Please Upload pdf File";  
}
}

?>

<form method="post" action="" enctype="multipart/form-data">
    <input type="file" name="file" />
    <input type="submit" name="submit" value="Upload" />
</form>

Check your $targetPath path is correct and give 777 permission for folder upload

Bachu 45 Newbie Poster

date ('d/m/y \a\t H:i');

OR

date ('d/m/y').' at '.date('H:i');

Bachu 45 Newbie Poster
<?php

$images = array('T1.jpg','I2.jpg','M3.jpg','E4.jpg');

$alt = array('Time','To','Tell','Toke');

foreach($images as $key=>$image) {
    echo '<img src="images/'.$image.'" alt="'.$alt[$key].'" />';
}

?>