Latest Web Development Posts

Machine learning is an application of artificial intelligence (AI) that provides systems the ability to automatically learn and improve from experience without being explicitly programmed. Machine learning focuses on the development of computer programs that can access data and use it learn for themselves.
You can read more on AI and ML in this blog : https://blog.eduonix.com/?s=machine+learning

You are duplicating HTML fields instead of setting them up as an array:

<td><input type="text" value="<?php echo $row['student_id']; ?>" name="student_id" ></td>
<td><input type="text" value="<?php echo $row['fname']; ?>" name="fname" >

Try this:

 <td><input type="text" value="<?php echo $row['student_id']; ?>" name="student_id[]" ></td>
 <td><input type="text" value="<?php echo $row['fname']; ?>" name="fname[]" >

But then unfortunately, you only deal with ONE sent ID in your handling code:

if(isset($_POST['submit']) ) {
    $tempDir = 'temp/'; 
    $student_id = $_POST['student_id']; //this is a single item
    $fname =  $_POST['fname']; //single item
    $filename = getUsernameFromEmail($student_id); 
    $codeContents = 'mailto:'.$student_id.'?id='.urlencode($student_id).'&fname='.urlencode($fname); 
    QRcode::png($codeContents, $tempDir.''.$filename.'.png', QR_ECLEVEL_L, 5);
}

In order to deal with an array of values, you need to use a loop (foreach or for or while) to iterate over each one. Alternatively, perhaps you could use some snazzy array functions, but these tend to take more processing than dealing with a simple loop.

<?php
include('qrlib.php'); 
    function getUsernameFromEmail($student_id) {
        $find = '@';
        $pos = strpos($student_id, $find);
        $username = substr($student_id, 0, $pos);
        return $username;
    }
    if(isset($_POST['submit']) ) {
        $tempDir = 'temp/'; 
        $student_id = $_POST['student_id'];
        $fname =  $_POST['fname'];
        $filename = getUsernameFromEmail($student_id);

        $codeContents = 'mailto:'.$student_id.'?id='.urlencode($student_id).'&fname='.urlencode($fname); 
        QRcode::png($codeContents, $tempDir.''.$filename.'.png', QR_ECLEVEL_L, 5);
    }
?>
Form:

<form id="demo-form2" method="post"  data-parsley-validate class="form-horizontal form-label-left" > 

                                      <table id="datatable" class="table table-striped table-bordered">
                  <thead>
                    <tr>
                      <th>Student Id</th>
                      <th>First Name</th>
                      <th>Actions</th>

                    </tr>
                  </thead>
                      <tbody>
                        <?php
                            include("includes/connection2.php");

                            $sql = "SELECT * FROM student";
                            $result=mysql_query($sql); //rs.open sql,con

                        while ($row=mysql_fetch_array($result))
                        { ?><!--open of while -->
                        <tr>
                            <td><input type="text" value="<?php echo $row['student_id']; ?>" name="student_id" ></td>
                            <td><input type="text" value="<?php echo $row['fname']; ?>" name="fname" ></td>
                        <td class="center">
                                <div class="form-group">
                    <input type="submit" name="submit" class="btn btn-primary submitBtn" style="width:20em; margin:0;" />
                </div>
                            </td>
                            <td class="center">

                            </td>   
                        </tr>
                                                            <?php
                           } //close of while
                        ?>
                      </tbody>
                       <?php
        if(!isset($filename)){
            $filename = "author";
        }
        ?>
        <div class="qr-field">
            <h3>QR Code Result: </h3>
            <center>
                <div class="qrframe" style="border:2px solid black; width:210px; height:210px;">
                    <?php echo '<img src="temp/'. @$filename.'.png" style="width:200px; height:200px;"><br>'; ?>
                </div>
    <a class="btn btn-primary submitBtn" style="width:50px; margin:1px 0;" href="download.php?file=<?php echo $filename; ?>.png ">Download QR Code</a>
            </center>
        </div>
                </table>
                        </div>
                </div>
              </div>
            </div>
</div>
        </div>   
                </form>

Hello Experts!
I am stuck here while generating QR Code using php sql. Basically I am generating code for students using their ids and other information while fetching data from database. But the problem is that when i click on submit button so that table data store in QR Code, then it only generate the QR Code of of only last one student. For Example if i have 6 students, it only generate the qr code of student whose id is 6.
Code is here:

can you please tell me if any one search result come ! please sure

I am following the below module,

https://www.webslesson.info/2018/04/shopping-cart-by-using-bootstrap-popover-with-ajax-php.html

How can i use without quantity [Product Name, Price, total, Action] i tried lot fail again and again. I am learning stage in PHP, any help pls welcome.

I am having problem in submitting this form when I select "1" on the number of setting in html form. The submit button is working if I select 2 in the number of sitting from html form as it will show all the form fields but when I select 1, submit form is not working. I am new to PHP

This is my html form

<form name="register" method="POST" action="process.php">
<label>Select Number of Sitting(s)</label>
<select name="sitting" id="sitting" class="form-control" onchange="showDiv(this)">
    <option value="1">1</option>
    <option value="2">2</option>
</select>
<div class="output1" id="div1" name="onesitting">
<label>School Name</label>
<input type="text" name="schoolname[]" id="schoolname1" class="form-control" placeholder="School Name" required>
<label>Exam Type</label>
<select name="examboard[]" id="examboard1" class="form-control" required>
    <option value="">Exam Type</option>
    <option value="WAEC">WAEC(SSCE)</option>
     <option value="WAEC">WAEC(GCE)</option>
        </select>
    </div>
<div class="form2a" id="div2a" name="twositting">
<h4 style="text-align:center; margin-top: 10px; margin-bottom: 5%; background-color:#0d4115; width: auto; color: white;">SECOND SITTING</h4>
<label>School Name</label>
<input type="text" name="schoolname[]" id="schoolname2" class="form-control" placeholder="School Name" required>
<label>Exam Type</label>
<select name="examboard[]" id="examboard2" class="form-control" required>
<option value="">Exam Type</option>
<option value="WAEC">WAEC(SSCE)</option>
<option value="WAEC">WAEC(GCE)</option>
</select>
 </div>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="table table-borderless" id="example">
 <tr>
            <td width="12%"><label class="control-label">S/NO</label></td>
            <td width="53%"><label class="control-label">SUBJECTS</label></td>
            <td width="35%"><label class="control-label">GRADE</label></td>
        </tr>
        <tr>
            <td>1</td>
            <td>
                <?php include("config.php");
                    $sql = "SELECT * FROM subjects ORDER BY subject_name ASC";
                    $query = mysqli_query($conn, $sql);
                    $count  = mysqli_num_rows($query);
                 ?>
                <select name="subjects[]" class="form-control" id="subject">
                    <option value="" selected="selected">Select subject</option>
                    <?php 
                        if($count > 0){
                            while($row = mysqli_fetch_assoc($query)){
                            $subject_id = $row['subject_id'];
                            $subject_name = $row['subject_name'];
                            echo "<option>" . $row['subject_name'] . "</option>";
                            }
                        }else{
                            echo "<option value = ''>Subject not available</option>";
                        }
                    ?>
                </select>
            </td>
            <td>
                <select name="grades[]" class="form-control">
                    <option value=""> Select</option>
                    <option value="A1">A1</option>
                    <option value="B2">B2</option>
                </select>
            </td> ...

OK for this you need to have a new table. Let's call it game_images for now. You will need a minimum of three fields: id (pk) , game_id (fk), filename.

To keep it as simple as possible we'll assume that all your game images are stored in the same folder that is stored in your php code or in other dB table.

When you create a new game. Your form should have the option of uploading images too. When you get to handle the form data in your php file, add the new game as before but crucially, get the last added id before any other operations. You can then use that id, which will be the game_id to add new records to your game_images table. Be aware if you pass multiple images, all with the same html name attribute, the resulting $_FILES array may have a different structure to which you may expect. Try a few things and come back if stuck.

hi brothers, am just new here.
i am now learning how to code, is there anyway you guys can help me develop a school management system with ,
staff payroll and payslip? please.

rproffitt commented: In a 9 year old discussion? No. Create your new discussion with links to your current work (on some Github or such.) Burying here won't bear fruit. +15

I am learning database and php

I have made a database with a list of my game collection with the following fields,

  1. ID
  2. game_name
  3. game_year
  4. platform
  5. publisher_name
  6. media
  7. owned
  8. finished
  9. completed
  10. launcher

I made this database in phpMyAdmin and would now like to add images of the games and the end of the database. This is for me and will not be going on the internet, so the images will be on my computer, I have searched for answers on the web and can not find any. I want to be able to add the images to the existing database and not setup a PHP script , is there a way to upload images within phpMyAdmin use the folder instead of the blob.

I have displayed the fields above a Localhost but would like to add an image to the page.

So if anybody could help,

Current versions of Java do support multiple inheritance from interfaces. So your question is in error.

rproffitt commented: That's what I thought. Then again they tagged the discussion with asp.net and left out Java version in use. I have a legacy app on (gasp) 1.8. +15

Hi, I am John and pursuing graduate, my question is why Java or oops language does not use multiple inheritance? This is nightmare for me. My exam is coming soon. Please provide me a good answer

Dani 1,760

You can try https://codecanyon.net/ which is an Envato Market (same parent company as Theme Forest) but designed for scripts and plugins instead of templates. Perhaps you were just trying to post within the wrong marketplace type?

Hey!

I am a bit stuck with my htaccess... let me explain how I want it to work...

I have a wildcard subdomain, for example, demo1.domain.com, demo2.domain.com...
I want htaccess to take whatever the subpart of the domain is and pass it as a variable...

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] 

RewriteCond %{HTTP_HOST} !^www\.domain.org.uk
RewriteCond %{HTTP_HOST} ^(.+).domain.org.uk
RewriteRule ^([^/]*)$ http://domain.org.uk/app/index.php?id=%1 [P,L,QSA]

This works and I can get the variable ID... I then use the to query a database and get the users database details and settings etc and save them into Sessions...

Then I want to be able to redirect them to http://demo1.domain.com/app/login/

Where it then loads /app/login.php and also passed any variables... such as /app/login/?cmd=update = /app/login.php?cmd=update..

However I can't get the latter part working... any help would be amazing!

Thanks
Dan

I think that you need to create own website.

I don't think JParker will ever come back to his thread, but here's my take on it.

For UI elements such as his sorting arrows and icons, it's common to use an (external) SVG sprites image and display them with <svg> <use> instead of a regular <img> tag.
The SVG sprites can be placed straight in the HTML, but if you want to keep your HTML 'clean' from all this messy SVG syntax, you can make an external SVG sprites image and use the SVG fragment identifier to grab the right SVG symbol out of it.

So let's say you have an up and down arrow and some social media icons, your SVG sprite will look like this:

<svg xmlns="http://www.w3.org/2000/svg">
    <symbol id="arrow-up" viewBox="0 0 8 8">
        <path d="M17.231 16L24 9.231 22.769 8 16 14.769 9.231 8 8 9.231 14.769 16 8 22.769 9.231 24 16 17.231 22.769 24 24 22.769 17.231 16z"/>
    </symbol>
    <symbol id="arrow-down" viewBox="0 0 8 8">
        <path d="M17.231 16L24 9.231 22.769 8 16 14.769 9.231 8 8 9.231 14.769 16 8 22.769 9.231 24 16 17.231 22.769 24 24 22.769 17.231 16z"/>
    </symbol>
    <symbol id="icon-instagram" viewBox="0 0 32 32">
        <path d="M7.547 0C3.39 0 0 3.39 0 7.547v10.906C0 22.61 3.39 26 7.547 26h10.906C22.61 26 26 22.61 26 18.453V7.547C26 3.39 22.61 0 18.453 0zm0 2h10.906A5.53 5.53 0 0 1 24 7.547v10.906A5.53 5.53 0 0 1 18.453 24H7.547A5.53 5.53 0 0 1 2 18.453V7.547A5.53 5.53 0 0 1 7.547 2zM20.5 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 ...
Dani 1,760

JParker, is your code not working? We’re you able to ever figure this one out?

    <?php
    session_start();
    if (!isset($_SESSION["username"])) {
            header("userLogin/?notloggedin=true"); //may need to use absolute or different relative address
            exit;
    }elseif($_SESSION["user_group"] !== 'admin') {
            header("whateverPage/?notadmin=true"); //may need to use absolute or different relative address
            exit;
    }
    //carry on with showing the page if logged in and admin
    ?>

You need to use <img src="" />. Svg tag use only for code

Hi i'm anis, how can i attach images from database to fpdf?

My code about filterable audio searching, here how can i add Add-To-Cart functionality?

code :
index.php

<?php 

//index.php

include('database_connection.php');

?> <!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"> <meta name="description" content=""> <meta name="author" content=""> <title>Voice Repository</title> <script src="js/jquery-1.10.2.min.js"></script> <script src="js/jquery-ui.js"></script> <script src="js/bootstrap.min.js"></script> <link rel="stylesheet" href="css/bootstrap.min.css"> <link href = "css/jquery-ui.css" rel = "stylesheet"> <!-- Custom CSS --> <link href="css/style.css" rel="stylesheet"> </head> <body> <!-- Page Content --> <div class="container"> <div class="row"> <br /> <div class="col-md-12"> <h2 align="center">Voice Repository Bank</h2> </div> <div class="col-md-3"> <!-- Price --> <!-- <div class="list-group"> <h3>Price</h3> <input type="hidden" id="hidden_minimum_price" value="0" /> <input type="hidden" id="hidden_maximum_price" value="65000" /> <p id="price_show">1000 - 65000</p> <div id="price_range"></div> </div> --> <!-- Languages  --> <div class="list-group"> <h3>Languages</h3> <?php
                    $query = "
                    SELECT DISTINCT(voice_languages) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_languages DESC
                    ";
                    $statement = $connect->prepare($query);
                    $statement->execute();
                    $result = $statement->fetchAll();
                    foreach($result as $row)
                    {
                    ?> <div class="list-group-item checkbox"> <label><input type="checkbox" class="common_selector languages" value="<?php echo $row['voice_languages']; ?>"  > <?php echo $row['voice_languages']; ?> </label> </div> <?php
                    }
                    ?> </div> <!-- Genres  --> <div class="list-group"> <h3>Genres</h3> <?php

                    $query = "
                    SELECT DISTINCT(voice_genres) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_genres DESC
                    ";
                    $statement = $connect->prepare($query);
                    $statement->execute();
                    $result = $statement->fetchAll();
                    foreach($result as $row)
                    {
                    ?> <div class="list-group-item checkbox"> <label><input type="checkbox" class="common_selector genres" value="<?php echo $row['voice_genres']; ?>" > <?php echo $row['voice_genres']; ?> </label> </div> <?php    
                    }

                    ?> </div> <!-- Voice Modulation --> <div class="list-group"> <h3>Voice Modulation</h3> <?php
                    $query = "
                    SELECT DISTINCT(voice_voice_modulation) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_voice_modulation DESC
                    "; ...

I am using the following code to check the user permission (User Role).

This is to check whether the user is logged in or not

<?php
    session_start();
    if (!isset($_SESSION["username"])) {
        echo '<script>window.location.href = "userLogin/?notloggedin=true";</script>';
    }
?>

This is to check whether is an admin or not

    <?php
        session_start();
        if ($_SESSION["user_group"] == 'admin') {
            //Display the current page.
        }
        else
            {
                //display an full page error without showing any other content in the current page.
            }
    ?>

My question is, how can I display a full page error instead of page content?

Dani 1,760

This is the code behind the demo at https://www.daniweb.com/connect/oauth/demo

Multiple database select - but print ids separately

$sql = "SELECT * FROM peron, peronmedia WHERE peronmedia.PID=5" and peron.ID=5"; $xc = mysqli_query($baglanti, $sql); $rs=mysqli_fetch_array($xc);

echo $rs["peron.PID"];
echo $rs["peronmedia.ID"];

but the codes don't work

How can I do it?

Thank you.

Welcome to DaniWeb. I wonder if you clicked the submission button too soon and forgot to add a question such as:

Why do I get the error "failed to open stream"?

<?php

 require_once('../vendor/autoload.php');

if (!isset($_POST["cart_payload"])) {
    echo "PAYLOAD NOT SET";
}

$items = json_decode($_POST["cart_payload"], true);
$line_items = array();
foreach ($items as $item) {
    $line_items[] = array(

$target = 'images/'; 
$target = $target . basename( $_FILES['image']['name'])
        'name' => $item["title"],
        'image' => $FILES["image"],
        'amount' => $item["price"]*100,
        'currency' => 'gbp',
        'quantity' => $item["quantity"],
    );
}

// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
 \Stripe\Stripe::setApiKey('sk_test_Bv1CxPqIn7LFeZ8MGvUKHu0h00rFUx2JlI');

$session = \Stripe\Checkout\Session::create([
    'payment_method_types' => ['card'],
    'line_items' => $line_items,
    'success_url' => 'https://skatelandnottingham.co.uk',
    'cancel_url' => 'https://skatelandnottinghamk.co.uk/events/',
 ]);

I know this responce is not needed for the original question, but could be used by people finding it later as an example.

$all is not needed. Since all is used to determine if the dates are used in an sql query, then the dates being supplied further determine the inclusion, only the later are needed, and are also optional. So, if they are not supplied in the function call, set them to 0 (zero).

function Get_All_Orderlines_Range($id, $from_date = 0, $to_date = 0){...}

Then you can remove:

if($all != "ALL"){

and just do:

if(!$from_date and !$to_date){
    $sql .=" AND (orders.OR_DATE_CREATED BETWEEN '" . $from_date . "' AND '" . $to_date . "')";
}

Here you are checking to see if both dates are supplied.

Warning:
Since this is a SELECT query, not as vital, but still important.

  • Varify that the variables are actual dates and are in the correct format before using them in sql statements.
  • Similar types of tests need to be used on the $id.

If you put a click handler on the body, than everything inside the body, like your content div, will also trigger that click and that's not what you want. I know you said you don't want a modal, but you can use the same technique most modals use for this to close the modal and that is by adding an overlay div dynamically with JS, or jQuery in your case, which you positions behind your content div and then put the click handler on the overlay.

HTML:

<div class="content">
  content
</div>

CSS:

.overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.content {
  position: relative;
  z-index: 1;
}

jQuery:

var overlay = $('<div>', {'class':'overlay'}).appendTo('body');

$('.overlay').on('click', function () {
  window.location.href = "https://www.google.com";
});

Here's the above in a Codepen (with some extra CSS just for demo purposes), but I used an alert, because redirecting to Google or any other website is not possible in a Codepen.
https://codepen.io/gentlemedia/full/pmYXde

rproffitt commented: The example I looked at was Yahoo.com which appears to use similar or same as your answer. Works. +15

I think I see it. You created a routine that inserted and then duplicated that code for each item. Now there are differing opinions about this but if it works, leave it. Working code that you understand is better than code you understand today but not later.

Somewhat famous programming quote following.

When I wrote that, God and I knew how it worked. Now only God knows.

Please post human readable HTML