Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About sigmahokies

  • Rank
    Advanced Member

Profile Information

  • Gender
  • Location
    Richmond, VA
  1. All right, I'm trying to tell you that I'm trying to get all array from $srs in above of script into function below of loop in array, but problem is PHP still does not recognize $srs is defined from beginning of script; Look at image screen as example that need to be done.
  2. <?php $srs = array(); for ($section = 1; $section < 5; $section++) { for ($row = $section; $row < 10; $row++) { for ($seat = $row; $seat < 20; $seat++) { $srs[] = array( 'section_name' => $section, 'row_name' => $row, 'seat_name' => $seat); } } } output(convert_array($srs)); // Converts the array function convert_array($input) { return $input; } function output($obj) { echo "<pre>"; print_r($obj); echo "</pre>"; die; } ?> I'm trying to convert those array number to string, add implode() to make it happen, but seem PHP didn't recognize variable in $input. Like this implode("Section: ", $input) or (Section: ", $srs). Can you help me? Thanks, Gary
  3. All right gw1500se, Here my full code, but it is three file different. one html and two php. I use php file to upload video, I use one html to let anyone know (display on monitor) that file is exist in folder. upload file first: <?php ?> <!doctype html> <html> <head> <link href="css/upload.css" rel="stylesheet" type="text/css"> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <table class="table"> <tr> <td colspan="2" align="center" class="children"><label for="file1">Children:</label></td> </tr> <tr> <td>First Name:</td> <td><input type="text" name="first" required></td> </tr> <tr> <td>Last Name:</td> <td><input type="text" name="last" required></td> </tr> <tr> <td>School Name:</td> <td><input type="text" name="school" required></td> </tr> <tr> <td>Grade:</td> <td><select name="grade"> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> </select></td> </tr> <tr> <td>Age:</td> <td><input type="text" name="age" required></td> </tr> <tr> <td>Test Video:</td> <td><input type="radio" name="videos" value="Home">Home Alone</td> </tr> <tr> <td>&nbsp;</td> <td><input type="radio" name="videos" value="Breakfast">Tiffany Breakfast</td> </tr> <tr> <td>&nbsp;</td> <td><input type="radio" name="videos" value="Spider">Spider</td> </tr> <tr> <td class="lowerfont">Upload your video</td> <td><input type="file" name="file1" id="file1"></td> </tr> <tr> <td>&nbsp;</td> <td><input type="submit" name="video" value="Upload your video"></td> </tr> </table> </form> <h2><a href="deletevideo.php" style="margin-left: 550px; color: white; text-decoration: none;">Go to Delete Video site</a></h2> <h2><a href="list.html" style="margin-left: 550px; color: white; text-decoration: none;">Return to list site</a> </h2> <div class="check"></div> </body> </html> now, run to upload site... [/php] <?php require ("access.php"); // if the form was posted, process the upload if ($_POST['video']) { $path1 = "UPLOADS/Home/"; $path2 = "UPLOADS/Breakfast/"; $path3 = "UPLOADS/Spider/"; $scan1 = scandir($path1); $scan2 = scandir($path2); $scan3 = scandir($path3); $count1 = count($scan1) - 3; $count2 = count($scan2) - 3; $count3 = count($scan3) - 3; if($count1 !== 0) { header('location:exist.html'); }elseif ($count2 !== 0) { header('location:exist.html'); }elseif ($count3 !== 0) { header('location:exist.html'); } $first = $_POST['first']; $last = $_POST['last']; $school = $_POST['school']; $age = $_POST['age']; $grade = $_POST['grade']; $option = $_POST['videos']; if ($option == "Home") { $fileToMove = $_FILES['file1']['tmp_name']; $destination = "UPLOADS/Home/" . $_FILES['file1']['name']; } elseif ($option == "Breakfast") { $fileToMove = $_FILES['file1']['tmp_name']; $destination = "UPLOADS/Breakfast/" . $_FILES['file1']['name']; } elseif ($option == "Spider") { $fileToMove = $_FILES['file1']['tmp_name']; $destination = "UPLOADS/Spider/" . $_FILES['file1']['name']; } if ($first && $last && $school && $age && $grade && $option) { $GaryDB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $exec = $GaryDB->prepare("insert into Children (`FirstName`, `LastName`, `School`, `Grade`, `Age`) values (:firstN, :lastN, :school, :grade, :age)"); $exec->bindValue(':firstN', $first, PDO::PARAM_STR); $exec->bindValue(':lastN', $last, PDO::PARAM_STR); $exec->bindValue(':school', $school, PDO::PARAM_STR); $exec->bindValue(':grade', $grade, PDO::PARAM_STR); $exec->bindValue(':age', $age, PDO::PARAM_STR); $exec->execute(); if (move_uploaded_file($fileToMove, $destination)) { header('location: uploaded.html'); } else { header('location: failupload.html'); } } } ?> Now, exist.html... <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Exist video</title> <link href="css/upload.css" rel="stylesheet" type="text/css"> </head> <body> <h2>There is video inside, you need to delete it to first.</h2> <h2><a href="deletevideo.php">Delete site</a></h2> </body> </html> that's my full code in html and php
  4. Hi gw1500se, This part is not work to not send to other site name 'exist.html' if php find one video is inside folder in server. I notice server is still taking uploading file when file is exist already in folder. I'm trying to stop upload file into folder when there is one video or document inside folder already.
  5. Hi everyone, I'm still learning, but getting intermediate in PHP now, but it is still challenge to learn. I'm trying to have php check to see if one file inside folder in server, seem I could not get it right, but I tested it on other site, it works, but not this script, I don't understand why it won't work...maybe logical is wrong? here my code: if ($_POST['video']) { $path1 = "UPLOADS/Home/"; $path2 = "UPLOADS/Breakfast/"; $path3 = "UPLOADS/Spider/"; $scan1 = scandir($path1); $scan2 = scandir($path2); $scan3 = scandir($path3); $count1 = count($scan1) - 3; $count2 = count($scan2) - 3; $count3 = count($scan3) - 3; if($count1 > 0) { header('location:exist.html'); }elseif ($count2 > 0) { header('location:exist.html'); }elseif ($count3 > 0) { header('location:exist.html'); } But other site, it works: $scan = scandir($path); $count = count($scan) - 3; echo $count; if($count > 1){ echo "Hello yourself!<br />"; } Anyone will help will be appreciate! Thank you! Gary
  6. All right, here my original code - <!doctype html> <html> <head> <title>Stimulation Video Home Alone</title> <link href="css/grammar.css" rel="stylesheet" type="text/css"> <link rel="icon" href="images/sigma.png"> <script type="text/javascript" src="js/checkbox.js"></script> <script> function clickvideo() { let x = document.getElementById("btn"); document.getElementById("display").innerHTML = "<video width='430' controls style='border-radius: 5px;' height='240' type='mp4'>" + "<source src='UPLOADS/Breakfast/" + x + "'></video>"; } </script> </head> <form> <?php $video = opendir("UPLOADS/Breakfast/"); while(($listvideo = readdir($video)) !== FALSE) { if (preg_match("/^[^\.].*$/", $listvideo)) { echo "<input type='button' id='btn' value='".$listvideo."' onclick='clickvideo()'>&nbsp;"; } $videoList = $listvideo; } ?> </form> <body> <table class="table" border="1"> <tr> <td><a href="index.html"><img src="images/logo_new_final.jpeg" align="left" width="250" alt="Research"></a></td> <td rowspan="4"> <iframe height="650" width="800" src="--------------.php" frameborder="0"></iframe> </td> </tr> <tr> <td> <video width="450" controls style="border-radius: 5px;"> <source src="video/Ha_Demo.mp4"> </video> </td> </tr> <tr> <td> <div id='display'> <video width='450' controls style='border-radius: 5px;'> <source src="UPLOADS/Breakfast/<?php echo $videoList ?>"> </video> </div> </td> </tr> </table> </body> </html> That's my original script...loop in php works, it show have a name on button from files' name in folder, but I can't figure why javascript won't do onclick when I'm asking for which video i want to see, like you can push button to have other video source appear on page. I tried to use .value and .textContent to retrieve text on button to make a switch video source on current page.
  7. Hi gw1500se, I'm trying to create the loop that which read directory from folder with Javascript inside echo by loop like this - $file = opendir("htdocs/site/"); while($files = readdir($file)) { echo "<button onclick='test()'>".$files."</button><br />"; } it will create few button that will have text on buttons which list in folder. Right now, I'm trying to make function in JavaScript when someone click one of several buttons, then JavaScript should response to change file or video or image. like you saw some website has several button, then you click on one of those button to see switch image on website. Of course, i will use document.getElementByTagName("button") to retrieve text, but seem it didn't get text, even, i tried to add like .value and .textContent in JavaScript...still not work. If you want, I can put my original script in next time.
  8. Hi everyone, I want to know, will Javascript's onclick on button work in PHP while loop? I mean, If I out "onclick" with function inside html tag, then put html inside echo under while loop. Will JavaScript's onclick work? Like this script below: $i = 0; while( $i < 5) { echo "<button id='btn' onclick='test()'>Hello</button>"; $i++; } This loop will create 4 times loop with same echo with onclick, so will onclick call Javascript programming?
  9. seem it works, not need to have php to remind... Thank you, Barand Gary Taylor
  10. Hi everyone, I am trying to have "require" label on form. If someone did not select the option on list, then "require" label will appear in form after submit. Seem my code isn't work. what did I do wrong? <?php$buzz = $buzz2 = ""; if ($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($_POST['select'])) { $buzz = "<h2><color color='red'> >- </color></h2>"; $buzz2 = "<h2><color='red'> -< </color></h2>"; }} ?><!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>XXXXXX</title> <link href="default.css" rel="stylesheet" type="text/css"></head><body><fieldset><h1>XXXXXXX</h1> <table> <form action="login.php" method="post"> <select name="select"> <?php echo $buzz ?><option value="" >Please select the level</option><?php echo $buzz2 ?> <option value="Administrator">Administrator</option> <option value="License">License</option> <option value="Scorer">Scorer</option> </select> <caption>Please login to enter the site below:</caption> <tr><td>Username:</td><td class="td"><input type="text" name="user"></td></tr> <tr><td>Password:</td><td class="td"><input type="password" name="password"></td></tr> <tr><td colspan="2"><input type="submit" name="submitted" value="Login"></td></tr> </form> </table></fieldset></body></html> Thanks for helping Gary Taylor
  11. Dodgeitorelse, it is above already. it is my code in php. it is on first I post in this thread.
  12. Hi dodgeitorelse3, Yes. I am trying to add the data into the database. I need to make a flexible in array and column that can insert or update into database with any number of columns. For example, If table has three columns, then program can set the value to store data tp update or insert three data from input in HTML. Please forgive me, I'm ASL user, so English is my second language, I am doing my best to make this post is understandable.
  13. Barand, I tried that. I don't see any inside post in php.
  14. I cannot see what is inside $_POST in form during php is interpreting. if there is possible to see what is inside $_POST, Please show me how... Gary
  • 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.