Jump to content

sigmahokies

Members
  • Content count

    128
  • Joined

  • Last visited

Community Reputation

0 Neutral

About sigmahokies

  • Rank
    Advanced Member

Profile Information

  • Gender
    Male
  • Location
    Richmond, VA
  1. sigmahokies

    Valdiation

    seem it works, not need to have php to remind... Thank you, Barand Gary Taylor
  2. sigmahokies

    Valdiation

    Seem it doesn't work
  3. sigmahokies

    Valdiation

    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
  4. sigmahokies

    flexible in loop in array

    Dodgeitorelse, it is above already. it is my code in php. it is on first I post in this thread.
  5. sigmahokies

    flexible in loop in array

    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.
  6. sigmahokies

    flexible in loop in array

    Barand, I tried that. I don't see any inside post in php.
  7. sigmahokies

    flexible in loop in array

    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
  8. sigmahokies

    flexible in loop in array

    It doesn't work, the data did not get in the Database.
  9. sigmahokies

    flexible in loop in array

    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...
  10. sigmahokies

    flexible in loop in array

    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
  11. 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>
  12. sigmahokies

    Array in for or foreach from database

    It works!!! finally...Now, I can building the SQL execute! Thank you so much!
  13. sigmahokies

    Array in for or foreach from database

    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>"; } }
  14. 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>"; } } }
  15. sigmahokies

    two column in table in php

    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>"; } } ?>
×

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.