PHP - Moved: Radio Box To Display Database Data In Textbox
This topic has been moved to JavaScript Help.
http://www.phpfreaks.com/forums/index.php?topic=321339.0 Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=350859.0 Hi I try to build a login form in which the user enter its userid, and the system check in the database for the user name and present it There are several other fiels that should act the same way. the problem is that the description field not get the user name. I be glad if someone show me where is the problem here is the code i use: The index.php page <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <?php require_once(".Includes/GlDbOra.php"); $logonSuccess = false; //get user details if (isset($_POST['userid_typed'])) { $row = (DBOracle::getInstance()->get_user_details1($_POST['userid'])); if(!$row) { echo "The user code entered in invalid"; } else { ?> <input type="text" name="userid_desc" id="user_desc" class="regular_textbox" value=<?php echo $row('username'); ?> readonly="readonly" disabled="disabled" /> <?php } } ?> <html> <head> <meta charset="UTF-8"> <title>Login</title> <script type="text/javascript" src="../../php-ajax/jquery-3.5.1.js"></script> <link href="index.css" type="text/css" rel="stylesheet" madia="all"/> </head> <body> <div class="logon"> <form name="logon" id="logon" action="index.php" method="POST" > <span style="clear: both; float: left; margin-top: 20px; "> <label for="userid">User Id</label> <input type="text" name="userid" id="userid" class="left_radius_textbox" placeholder="<?php echo userid;?>"/> <input type="text" name="userid_desc" id="user_desc" class="regular_textbox" value="" readonly="readonly" disabled="disabled" /> <label for="password">Password</label> <input type="password" name="password" id="password" class="regular_textbox" placeholder="<?php echo password;?>"/> </span> <span style="clear: both; float: left; margin-top: 20px"> <label for="compid">Company</label> <input type="text" name="compid" id="compid" class="left_radius_textbox" placeholder="<?php echo compid;?>"/> <input type="text" name="compid_desc" id="compid_desc" class="regular_textbox" value="" readonly="readonly" disabled="disabled" /> <label for="language">Language</label> <input type="text" name="language" id="language" class="left_radius_textbox" placeholder="<?php echo language;?>"/> <input type="text" name="language_desc" id="language_desc" class="regular_textbox" value="" readonly="readonly" disabled="disabled" /> </span> <span style="clear: both; float: right; margin-top: 20px"> <input type="submit" value="Login"style="margin-right: 500px; border-radius: 40px ; text-align:center;width: 220px; height: 30px;" class="" placeholder="<?php echo login;?>"/> </span> </form> </div> <script> $(document).ready() { $("#userid").focusout() { var userid=$('input[name=userid]').val(); $.ajax ({ type:"POST", url:"../AmiDorGL/Includes/GlDbOra.php", data: { "userid_typed":1, "userid":userid, }, datatype:"text", success:function(response) { $("#userid_desc").html(response); } }); }; }; </script> </body> </html> the GlDbOra.php code: <?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ class DBOracle { private static $instance = null; private $OracleUser="xxx"; private $OraclePwd="xxx"; private $OracleDB="xxx"; public static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self; } return self::$instance; } // The clone and wakeup methods prevents external instantiation of copies of the Singleton class, // thus eliminating the possibility of duplicate objects. public function __clone() { trigger_error('Clone is not allowed.', E_USER_ERROR); } public function __wakeup() { trigger_error('Deserializing is not allowed.', E_USER_ERROR); } public function __construct () { $this->con = oci_connect($this->OracleUser, $this->OraclePwd, $this->OracleDB); if (!$this->con) { $m = oci_error(); echo $m['message'], "\n"; exit; } } public function get_user_details1($userid) { $query = "select first_name||' '||last_name username, password from users where userid = :userid_bv"; $stid = oci_parse($this->con, $query); oci_bind_by_name($stid, ':userid_bv', $userid); oci_execute($stid); $row = oci_fetch_array($stid, OCI_ASSOC); return $row; } }
Edited May 29, 2020 by requinix please use the Code <> button when posting code Here is a link to screenshots of what is happening, because I'm crappy at describing things: http://imgur.com/a/ahvPA Of course I've messed the code up somewhere, but I can't for the life of me figure out where. I have a simple page for someone to enter text in a textbox to save in a database to display on another page. There are 10 textboxes on the page. I can enter text into any and all textboxes and it'll save the data in the database, EXCEPT if I enter text into the 2nd textbox. If there's anything in the 2nd textbox after I click submit, it will delete whatever was in the 2nd textbox and move all data in each textbox (except textbox 1, which stays in the same place) down one element. And it pushes the data in the final textbox off the page (presumably because there's no other textbox to accept its data). Here is the code to the two pages affected. Any help would be appreciated! Code: [Select] <?php // start the session session_start(); if (!session_is_registered($_SESSION['myusername'])) { header ('location:./login.php'); } $i=1; require_once('./dbconnect.php'); $sql="SELECT `event` FROM `events`"; $result=mysql_query($sql); mysql_close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Admin Portal</title> </head> <body> <form name="events" method="post" action="eventlogging.php"> <table width="800" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#CCCCCC"> <strong><p><strong>Admin Portal</strong></p><p align="right"><small><a href="./logout.php">Logout</a></small> </td> </tr> <?php while ($i<11) { echo ' <tr align="center"> <td align="right" width="100">Event ' . $i . ' </td> <td width="800"> <textarea name=event' . $i . ' cols=40 rows=5>'; $row = mysql_fetch_array($result); if ($row) { $msg=$row[0]; echo $msg; }; $i++; echo '</textarea> </td> </tr> '; } ?> <tr> <td colspan="2"> <center><input type="submit" name="Submit" value="Submit" /></center> <input type="hidden" name="submitted" value="true" /> </td> </tr> </td> </tr> </table> </td> </tr> </table> </form> </body> </html> <?php $position = 1; $dbControl = 9; $event = array(); if (!empty($_POST['event1'])) { $event[] = $_POST['event1']; } if (!empty($_POST['event2'])) { $event[] = $_POST['event']; } if (!empty($_POST['event2'])) { $event[] = $_POST['event']; } if (!empty($_POST['event3'])) { $event[] = $_POST['event3']; } if (!empty($_POST['event4'])) { $event[] = $_POST['event4']; } if (!empty($_POST['event5'])) { $event[] = $_POST['event5']; } if (!empty($_POST['event6'])) { $event[] = $_POST['event6']; } if (!empty($_POST['event7'])) { $event[] = $_POST['event7']; } if (!empty($_POST['event8'])) { $event[] = $_POST['event8']; } if (!empty($_POST['event9'])) { $event[] = $_POST['event9']; } if (!empty($_POST['event10'])) { $event[] = $_POST['event10']; } include ('./dbconnect.php'); mysql_query("DELETE FROM `events`"); foreach ($event as $msg) { mysql_query("INSERT INTO `events` (`position`, `event`, `date`) VALUES ('$position', '$msg', curdate() )") or die(mysql_error()); $position++; } mysql_close(); $position=1; /* foreach ($event as $msg) { echo $position . '. ' . $msg . '<br />'; $position++; } */ header("location:./admin.php"); ?> I have page with male female radio button Here's the code Code: [Select] $qry=mysql_query("SELECT * FROM reg_table where id=$id "); $res=mysql_fetch_array($qry); $radio = $res['gender']; switch($radio) { case "male": $mal = "checked"; break; case "female": $fem = "checked"; break; } Code: [Select] Gender: <br /> <input type="radio" name="colour" value="male" checked="<?php $mal; ?>" />Male <input type="radio" name="colour" value="female" checked="<?php $fem; ?>" />Female Whats the use of checked in <input type="radio" name="colour" value="male" checked="<?php $mal; ?>" /> Hey in my edit page i have 2 radio buttons in my form and i need to make sure the same value is still selected how can i do that? thanks Hi I am trying to display data from the table "event" in my database, I use the code below but it will not work and I cannot figure out why. CAn anyone help? CODE: <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="event"; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $result = my_sql_query("SELECT * FROM event WHERE eventid = '1'"); while($row = mysql_fetch_array($result)) { $eventname= $row["eventname"]; $eventdate= $row["eventdate"]; echo "<b><u>Event Name:</b></u> $eventname" echo "<b><u>Event Date:</b></u> $eventdate<br>"; } ?> DISPLAY: Event Name: $eventname echo "Event Date: $eventdate "; } ?> im making a game and i need to show a users money but i dont know how help? how i want to display data from database to look like this : <table width="633" height="224" border="1"> <tr bgcolor="#999900"> <td width="45">Bil</td> <td width="121">Course_name</td> <td width="83">session</td> <td width="83">start_date</td> <td width="83">end_date</td> <td width="83">notes</td> <td width="89">pre-req</td> </tr> <tr bgcolor="#6A7AEA"> <td rowspan="2">1.</td> <td rowspan="2" bgcolor="#6A7AEA">Math</td> <td>1st session </td> <td>1 jan 11 </td> <td>6 jan 11 </td> <td rowspan="2"> </td> <td rowspan="2"><image icon that will link to the oter site> </td> </tr> <tr> <td bgcolor="#6A7AEA">2nd session </td> <td bgcolor="#6A7AEA">8 jan 11 </td> <td bgcolor="#6A7AEA">15 jan 11 </td> </tr> <tr> <td bgcolor="#0066CC">2.</td> <td bgcolor="#0066CC">English</td> <td bgcolor="#0066CC">1st session </td> <td bgcolor="#0066CC">1 feb 11 </td> <td bgcolor="#0066CC">6 feb 11 </td> <td bgcolor="#0066CC"> </td> <td bgcolor="#0066CC"><image icon that will link to the oter site></td> </tr> <tr> <td rowspan="2" bgcolor="#6A7AEA">3.</td> <td rowspan="2" bgcolor="#6A7AEA">Science</td> <td height="29" bgcolor="#6A7AEA">1st session </td> <td bgcolor="#6A7AEA">8 march 11 </td> <td bgcolor="#6A7AEA">15 march 11 </td> <td rowspan="2" bgcolor="#6A7AEA"> </td> <td rowspan="2" bgcolor="#6A7AEA"><image icon that will link to the oter site></td> </tr> <tr> <td bgcolor="#6A7AEA">2nd session</td> <td bgcolor="#6A7AEA">16 march 11 </td> <td bgcolor="#6A7AEA">21 march 11 </td> </tr> </table> ** all the view data is called from database including the icon image thanks... I have got connection to the the mysql database, how do I get the data from the database to display on the webpage hey guys so im trying to display data into text boxes that are fetched from database according to checkbox with value id. processing is located before <!DOCTYPE html>: if(isset($_POST['edit_event']) && isset($_POST['check'])) { require "connection.php"; foreach ($_POST['check'] as $edit_id) { $edit_id = intval($GET['event_id']); //i tried (int)$edit_id; $sqls = "SELECT event_name,start_date,start_time,end_date,end_time,event_venue FROM event WHERE event_id IN $edit_id "; $sqlsr = mysqli_query($con, $sqls); $z = mysqli_fetch_array($sqlsr); { }button and form opens: <form method="post" action="event.php"> <input type="submit" name="edit_event" value="Edit Event">this is the html where the data will be echoed: <div id="doverlay" class="doverlay"></div> <div id="ddialog" class="ddialog"> <table class="cevent"> <thead><tr><th>Update Event</th></tr></thead> <tbody> <tr> <td> <input type="text" name="en_" value="<?php echo $z['event_name']; ?>"> </td> </tr> <tr> <td> <input type="text" name="dates_" value="<?php echo $z['start_date']; ?>"> <input type="text" name="times_" value="<?php echo $z['start_time']; ?>"> </td> </tr> <tr> <td><input type="text" name="datee_" value="<?php echo $z['end_date']; ?>"> <input type="text" name="time_" value="<?php echo $z['end_time']; ?>"> </td> </tr> <tr> <td><input type="text" name="ev_" value="<?php echo $z['event_venue']; ?>"> </td> </tr> <tr> <td><input type="submit" name="update" value="Update Event" id="update"> <input type="submit" id="cancelupdate" name="cancel" value="Cancel" > </td> </tr> </tbody> </table> </div>this is the part which is populated by data from database where isset($_POST['check']) gets the 'check' from: echo "<tr> <td><input type='checkbox' name='check[]' value='$id'>$name </td> </tr>";</form> thanks in advance! Edited by noobdood, 19 May 2014 - 10:42 PM. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=342944.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=314051.0 Hi guys, Should be a simple 1. If i have the following at the top of the page: $page_views = $row['page_views'] + 1; mysql_query("UPDATE table SET page_views='$page_views'"); and then the following at the bottom of the page: echo $row['page_views']; Should I see the page views as 1 the first time the page is visited, 2 the second time the page is visited, and so on......? At the moment im seeing 0 on the first page visit, 1 on the second page visit, 2 on the third..... I had this problem before on another page i was working, and i simply solved it by displaying the mysql query above the echo similar to the code above. However now it does not seem to be working. Am i missing something really simple? lol Thanks This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=314247.0 This is actually a page to edit the drama details. Database- 3 tables 1. drama dramaID drama_title 1 friends 2. drama_genre drama_genreID dramaID genreID 1 1 2 2 1 1 3 1 3 3. genre genreID genre 1 comedy 2 romance 3 family 4 suspense 5 war 6 horror <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'drama'; $link = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or trigger_error('Error connecting to mysql'); $id = $_GET['dramaID']; $link2 = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or trigger_error('Error connecting to mysql'); $sql2 = "SELECT * from drama , drama_genre , genre WHERE drama.dramaID='".$id."' AND drama_genre.dramaID='".$id."' AND drama.dramaID = drama_genre.dramaID AND drama_genre.genreID = genre.genreID"; $status2 = mysqli_query($link2,$sql2) or die (mysqli_error($link2)); $link3 = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or trigger_error('Error connecting to mysql'); $sql3 = "SELECT * from genre "; $status3 = mysqli_query($link3,$sql3) or die (mysqli_error($link3)); <form method='Post' action='doUpdate.php' enctype="multipart/form-data"> <?php while ($row2 = mysqli_fetch_assoc($status2)) { ?> <td height="1"></td> <td><select name="gdrop"> <option value="<?php echo $row2['genreID'];?>"><?php echo $row2['genre'];?></option> <?php while ($row3 = mysqli_fetch_assoc($status3)) { ?> <option value="<?php echo $row3['genreID'];?>"><?php echo $row3['genre'];?></option> <?php } mysqli_close($link3); ?> <input type='hidden' id='drama_genreID' name='drama_genreID' value = "<?php echo $row2['drama_genreID']; ?>"/> </select> <input type="hidden" id="dramaID" name="dramaID" value = "<?php echo $row['dramaID'];?>"/> <input type="submit" Value="Update"/> The result was there were 3 dropdown menus but only the first dropdown menu has all 6 genres from my database and also the genre that belongs to the drama. I'm also wondering how I can bring all the drama_genreIDs to my save(doupdate.php) page and update all 3 of them because it seems like only the last dropdown menu's data is saved. And also how can I display only 6 genres instead of 7 with the genre that belongs to the drama , being set as the default selection. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=309973.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=305902.0 As a complete newbie to php and webdesigning i have a following problem.I would like to retrieve the data from database and display it in a drop down menu.Then i should allow the user to select the values from drop down list along with other details,in other words i have to embed the drop down output as the form input for the user and store the form data in another table.I am running a xampp server and i am using php 5.4 version.Please help.My code is as follows.In this case project_name is displayed as the drop down output.but how do i use the same drop down output as a input in the form. <html> <head></head> <body> <?php error_reporting(E_ALL ^ E_DEPRECATED); include 'connect.php' ; $tbl_name="projects"; $sql="SELECT project_name FROM $tbl_name "; $result=mysql_query($sql); if($result === FALSE) { die(mysql_error()); } ?> <form name="resources" action="hourssubmit.php" method="post" > <?php echo "<select name='project_name'>"; while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['project_name'] ."'>" . $row['project_name'] ."</option>"; } echo "</select>"; ?> </form> </body> </html> i have 8 division (div), i want to display 4 rows in 4 division and the remain 4 rows in the next 4 division here is my code structure for carousel
<div class="nyie-outer"> second row third row
fourth row fifth row sixth row seven throw eighth row
</div><!--/.second four rows here-->
sql code
CREATE TABLE product( php code
<?php how can i echo that result in those rows
|