Jump to content

sigmahokies

Members
  • Content Count

    136
  • Joined

  • Last visited

Everything posted by sigmahokies

  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
  15. It doesn't work, the data did not get in the Database.
  16. I just tried that as soon as you posted, seem it doesn't work. No error message, but result showed same - label[], label[], label[]. Not label0, label1, label2...
  17. Hello everyone, I'm getting there, but not perfect. Still learning to do write the script in PHP. Anyway, I am trying to get set up the flexible array and values in html and SQL. I am trying to make different name, cannot same name in loop. For example, in PHP, to get data value from $_POST from name from input in form area in html, so I can't figure how to get like array. In loop, look like: using for or foreach loop, I need to have <input type="text" name="label$j"> in different number, like to have loop name = label1, label2, label3... But I found php print the loop same - label1, label1, label1...I don't want that, because it will conflict to insert in the data in the database. here my code: <!doctype html> <html> <head> <title>Add name and number</title> <link href="defaultdatabase.css" rel="stylesheet" type="text/css"> </head> <h2>Add any DSDJ information to database</h2> <?php require ("require2.php"); $sql = "show tables from XXXX"; $list = mysqli_query($GaryDB, $sql); while ($row = mysqli_fetch_array($list)) { $table[] = $row[0]; } $option = ''; foreach ($table as $rows) { $option .= "<option value='{$rows}'>{$rows}</option>"; } ?> <form action="addname.php" method="post"> <table> <tr><th>Select the table</td><td> <select name="subject"> <?php echo $option; ?> </select></td><td><input type="submit" name="selected" value="select"></td></tr> </table> </form> <form> <table> <?php if (isset($_POST['selected'])) { $selected = $_POST['subject']; $column = "select column_name from information_schema.columns where table_name = '" . $selected . "'"; $list5 = mysqli_query($GaryDB, $column); while ($array = mysqli_fetch_array($list5)) { $input = ''; $j = 0; foreach ($array as $row5) { $input = "<tr><td>{$row5}:</td><td colspan='2'><input type='text' name='label$j'></td></tr>"; $j++; } echo $input; } if (isset($_POST['insert'])) { foreach ($array as $row6) { $ins = "{$row6},"; } foreach ($_POST['label'] as $row7) { $ins5 = "'{$row7}',"; } $insert = "insert into " . $selected . " (" . $ins . ") values (" . $ins5 . ")"; $added = mysqli_query($GaryDB,$insert); if($added) { echo "<tr><td>Data are insert into Database</td></tr>"; } else { echo "<tr><td>Data did not get in the Database</td></tr>"; } } }echo "<tr><td><input type='submit' name='insert' value='Add data in database'></td></tr>"; ?> </table> </form> </html> So, in result: <tr><td>Articles_ID:</td><td colspan='2'><input type='text' name='label1'></td></tr><tr><td>Subject_ID:</td><td colspan='2'><input type='text' name='label1'></td></tr><tr><td>ID:</td><td colspan='2'><input type='text' name='label1'></td></tr><tr><td>LastName:</td><td colspan='2'><input type='text' name='label1'></td></tr><tr><td><input type='submit' name='insert' value='Add data in database'></td></tr> Look at result name in label1, label1, label1, ...that is no no no. I want to have label1, label2, label3...can you help? Thank you so much! Gary Taylor
  18. Hi everyone, I am trying to make it simply, but seem error come repeatedly, I could not figure why it went wrong. I am trying to get print (echo) to visible the print before I build other script. but resilt said "Notice: Array to strong conversion in" what did I do wrong? Thanks, Gary <!doctype html><html><body><table><?php require("require2.php"); $show = "show tables from XXXX";$table = mysqli_query($GaryDB, $show);$array = array();while($array = mysqli_fetch_array($table)) { echo $array;}?></table></body></html>
  19. It works!!! finally...Now, I can building the SQL execute! Thank you so much!
  20. Hi everyone again, I made mistake...but still not work. here my recode in PHP $show = "show tables from XXXX"; $table = mysqli_query($GaryDB, $show); while($row = mysqli_fetch_array($table)) { $tables[] = $row; for($i = 0; $i < count($tables); $i++) { $list = "<option value='".$tables[$i]."'>".$tables[$i]."</option>"; } }
  21. Hi everyone, I am still learning PHP. I am trying to get data from database which "show tables from (ojbect)" that pour into array, then set them up in the select and option in HTML, I can't figure why it won't work to get data from table to get in loop as for and foreach. I don't think "[ ]" will help in PHP, will it? Can anyone please help me? thank you so much! $show = "show tables from XXXX"; $table = mysqli_query($GaryDB, $show); while($row = mysqli_fetch_array($table)) { $tables = array($row); foreach($tables as $select) { for($i = 0; $i < count($select); $i++) { $list = "<option name='choose' value='".$select[i]."'>".$select[i]."</option>"; } } }
  22. Sepodati and Psycho, I found a way to solution my problem. Hey, Psycho, I used your method of array at top of script of php, then I used Sepodati's body of foreach, it works! Let me show you a code: <?php require('require.php'); $list = "select FirstName, LastName from Members"; $display = mysqli_query($GaryDB,$list); $record = array(); $count = 0; if(mysqli_num_rows($display)) { while($row = mysqli_fetch_assoc($display)) { $record[] = $row; } foreach($record as $z) { if($count % 2 == 0) { echo "<tr>"; } echo "<td>".$z['FirstName']." ".$z['LastName']."</td>"; if($count % 2 == 1) { echo "</tr>"; } $count++; } if($count % 2 == 1) { echo "<td> </td></tr>"; } } ?>
  23. requinix, I tried your script, but it doesn't work, it is "infinite: loop, I have to stop this loop. anyone can make a suggest?
  24. Sepodati, I am asking for second of your paragraph, like this: | person 1 | Person 2 | | Person 3 | Person 4 | Now, I am trying other reply who make a suggest to me...
×
×
  • 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.