PHP - Not Showing Data
I am developing hospital managment system using php. I have IPD data sheet. When I select patient it is not showing pt data as it should do. Please let me know if any coding needs to place here. I am new to PHP. Below is my code <?php //create array to temporarily grab variables $input_arr = array(); //grabs the $_POST variables and adds slashes foreach ($_POST as $key => $input_arr) { $_POST[$key] = addslashes($input_arr); } ?> <?php session_start(); $db = mysqli_connect('localhost', 'root', '', 'ratanba_new'); // initialize variables $reg_no = ""; $name = ""; $father_name = ""; $sir_name = ""; $sex = ""; $age = ""; $full_name = ""; $dob = ""; $update = false; $patient_master_id = ""; $ipd_id = 0; $IPNo = ""; $fees = ""; $opd_date = ""; $pulse = ""; $bps = ""; $bpd = ""; $weight = ""; $spo2 = ""; if (isset($_POST['admit'])) { function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); $data = ucwords($data); return $data; } $patient_master_id = $_POST['patient_master_id']; $IPNo = $_POST['IPNo']; $RegNo = $_POST['reg_no']; $Name = $_POST['Name']; $Age = $_POST['Age']; $Sex = $_POST['sex']; $Contact1 = $_POST['Contact1']; $Relation1 = $_POST['Relation1']; $Mobile1 = $_POST['Mobile1']; $Contact2 = $_POST['Contact2']; $Relation2 = $_POST['Relation2']; $Mobile2 = $_POST['Mobile2']; $Adate = $_POST['Adate']; $Award = $_POST['Award']; mysqli_query($db, "INSERT INTO IPD (IPNo, RegNo, Name, Age, Sex, Contact1, Relation1, Mobile1, Contact2, Relation2, Mobile2, Adate, Award) VALUES ('$IPNo', '$RegNo', '$Name', '$Age', '$Sex', '$Contact1', '$Relation1', '$Mobile1', '$Contact2', '$Relation2', '$Mobile2', NOW(), '$Award')"); $_SESSION['message'] = "New Admission Successfull !"; header('location: ../ipd.php'); } if (isset($_POST['Discharge'])) { $ipd_id = $_POST['ipd_id']; $Outcome = $_POST['Outcome']; mysqli_query($db, "UPDATE ipd SET Outcome='$Outcome', Ddate=NOW() WHERE ipd_id=$ipd_id"); $_SESSION['message'] = "Patient discharged Successfull !"; header('location: ../ipd.php'); } if (isset($_POST['final_discharge'])) { $ipd_id = $_POST['ipd_id']; $History = $_POST['History']; $Examination = $_POST['Examination']; $Investigation = $_POST['Investigation']; $Advise = $_POST['Advise']; $Diagnosis = $_POST['Diagnosis']; $Treatment = $_POST['Treatment']; $Operation = $_POST['Operation']; $OTnote = $_POST['OTnote']; $Condition1 = $_POST['Condition1']; $Note = $_POST['Note']; mysqli_query($db, "UPDATE ipd SET History='$History', Examination='$Examination', Investigation='$Investigation', Diagnosis='$Diagnosis', Operation='$Operation', OTnote='$OTnote', Condition1='$Condition1', Advise ='$Advise', Treatment='$Treatment', Note='$Note' WHERE ipd_id=$ipd_id"); $_SESSION['message'] = "Discharge saved Successfull !"; header('location: ../doctor/discharge.php'); } $results = mysqli_query($db, "SELECT * FROM IPD "); ?> Edited May 8 by Barand Coding was missed Similar TutorialsThe following code should output 1743425391, but it does not show anything <?php $xml_feed_url = 'http://api.eve-online.com/eve/CharacterID.xml.aspx?names=TX1'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $xml_feed_url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $xml = curl_exec($ch); curl_close($ch); $xmlr = new SimpleXMLElement($xml); $charid = $xmlr->result->characterID; echo $charid; ?> The xml is: Code: [Select] <eveapi version="2"> <currentTime>2011-02-01 05:22:38</currentTime> − <result> − <rowset name="characters" key="characterID" columns="name,characterID"> <row name="TX1" characterID="1743425391"/> </rowset> </result> <cachedUntil>2011-03-01 05:22:38</cachedUntil> </eveapi> Any ideas where I went wrong? Hi: Can someone tell me why the code below is not displaying any data. It's suppose to write the calendar dates and event info, but nothing is showing up. No errors, either .. ?? Code: [Select] <td width="50" <?=hiLightEvt($month,$i,$year);?>> <?php if(isset($_GET['full'])){ $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['calName']; }else{ $sql="select calID, calDate, calName, calDesc from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo $row['calName']; ?> <a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$row['calDate'];?></a> <?php } } ?> </td> Help, please .... Hi all, I want to create a website, where the user can add any number of custom fields, and then put any info there he or she wants. I then need a site to display the info. The problem is that I have no idea on what would be the smartest way to do this. Let's say it was about flowers and they created a "type" field and a "stock" field. How could i make sure, that the correct stock will be displayed with the correct type field? I am having an issue with the data from page ID 5 not displaying in the form, Why <?php include('includes/header.php'); include('includes/class/class.form.php'); include('includes/class/class.page.php'); $iPageID = 5; if(isset($_GET["PageID"])){ $iPageID = $_GET["PageID"]; } $EditedPage = new Page(); $EditedPage->loadPage(5); $apageInformation = array(); // Information From DB Sticky $apageInformation["name"] = $EditedPage->getPageName(); $apageInformation["content"] = $EditedPage->getPageContent(); $formEdit = new Form('editpage.php?PageID=".$iPageID', 'EditPage','return CheckEditPage();',''); $formEdit->setStickyData($apageInformation); if(isset($_POST["submit"])){ $formEdit->setStickyData = $_POST; $formEdit->checkNotEmpty("Name"); $formEdit->checkNotEmpty("PageContent"); if($formEdit->getValid() == true){ $EditedPage->setPageName = $database->escape_value($_POST["Name"]); $EditedPage->setPageContent = $database->escape_value($_POST["PageContent"]); $EditedPage->savePage(); $Message = "Page Updated"; }else{ $Message = "You Have An Error Mate"; } } $formEdit->openFieldset(); $formEdit->makeInputBox("Name","Name","CheckInput(this.id);"); $formEdit->makeTextArea("Content", "PageContent", "20","70", "CheckInput(this.id);"); $formEdit->makeSubmitButton("submit","Edit Page"); $formEdit->closeFieldset(); $newNavigation = new Navigation(); ?> <?php echo $newNavigation->mainMenu();?> <h1 class="Heading">Edit Page</h1> <?php echo $Message ?> <?php echo $formEdit->getHTML(); ?> <?php include('includes/footer.php')?> <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("contact", $con); $sql="INSERT INTO contact_info (FirstName, LastName, Phone, Email, ContactMethod, City, State, zip, TimeFrame, Agent, AgentInfo) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[phone]','$_POST[email]','$_POST[contactmethod]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[timeframe]','$_POST[agent]','$_POST[agentinfo]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> That's my code everything seem's to be working fine script runs and says 1 record added however when I go to view the entry phpMyAdmin the entry show's up without the data? Hello, I have done this with SimpleXML variables many times. I seem to be struggling with something really simple as I am venturing out with some JSON. Basically there is a variable $nowcast. Sometimes that node may be empty. So I want to display an alternative message if it is empty like it is now. Unfortunately I am having some struggles and can't get the message to display when the node is empty. What am I missing?
-Thanks
// Lets get parse the data and create the variables $json_string = file_get_contents("http://api.wunderground.com/api/REMOVED_KEY/geolookup/conditions/q/TX/Mesquite.json"); $parsed_json = json_decode($json_string); $Updated = $parsed_json->{'current_observation'}->{'observation_time'}; $location = $parsed_json->{'location'}->{'city'}; $nowcast = $parsed_json->{'current_observation'}->{'nowcast'}; // Lets make some style classes for your divs $divContainer = "width:{$divWidth};background-color:{$bkgColor};color:{$txtColor};border:{$border} 1px solid;font-size{$fontSize};"; $divHeader = "width:100%;background-color:{$titleBar};"; $divWrapper = "padding: 5px 5px 5px 5px;"; $pStyle = "color:{$titleTxt};margin:0 0 2px 2px;"; // If there is an available message display it $nowCast = "<h3 class='title'>NWS NowCast<span style='float:right'> {$Updated}</span></h3>"; $nowCast = "<hr />"; $nowCast = "<div class='NWSRound'>"; $nowCast = "<div style='{$divWrapper}'> {$nowcast}</div>"; $nowCast = "</div>"; $nowCast = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tbody><tr><td><img alt='' src='images/1pixel.gif' border='0' height='7' width='7' /></td><td class='shadow-mid' width='100%'><img alt='' src='images/1pixel.gif' border='0' height='7' width='7' /></td><td><img alt='' src='images/1pixel.gif' border='0' height='7' width='7' /></td></tr></tbody></table>"; // If there is no available message then lets display the following $noMessage = "<h3 class='title'>NWS NowCast<span style='float:right'> {$Updated}</span></h3>"; $noMessage = "<hr />"; $noMessage = "<div class='NWSRound'>"; $noMessage = "<div style='{$divWrapper}'> No valid short term forecast for {$location} currently available at this time</div>"; $noMessage = "</div>"; $noMessage = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tbody><tr><td><img alt='' src='images/1pixel.gif' border='0' height='7' width='7' /></td><td class='shadow-mid' width='100%'><img alt='' src='images/1pixel.gif' border='0' height='7' width='7' /></td><td><img alt='' src='images/1pixel.gif' border='0' height='7' width='7' /></td></tr></tbody></table>"; if(count(json_decode($nowcast,1))==0) { echo $nowCast; } else { echo $noMessage; } Edited by Texan78, 16 December 2014 - 10:44 PM. Hello: I have a SELECT dropdown menu that works like this: Code: [Select] <?php $states_arr = array('AL'=>"Alabama",'AK'=>"Alaska",'AZ'=>"Arizona",'AR'=>"Arkansas",'CA'=>"California",'CO'=>"Colorado",'CT'=>"Connecticut",'DE'=>"Delaware",'DC'=>"District Of Columbia",'FL'=>"Florida",'GA'=>"Georgia",'HI'=>"Hawaii",'ID'=>"Idaho",'IL'=>"Illinois", 'IN'=>"Indiana", 'IA'=>"Iowa", 'KS'=>"Kansas",'KY'=>"Kentucky",'LA'=>"Louisiana",'ME'=>"Maine",'MD'=>"Maryland", 'MA'=>"Massachusetts",'MI'=>"Michigan",'MN'=>"Minnesota",'MS'=>"Mississippi",'MO'=>"Missouri",'MT'=>"Montana",'NE'=>"Nebraska",'NV'=>"Nevada",'NH'=>"New Hampshire",'NJ'=>"New Jersey",'NM'=>"New Mexico",'NY'=>"New York",'NC'=>"North Carolina",'ND'=>"North Dakota",'OH'=>"Ohio",'OK'=>"Oklahoma", 'OR'=>"Oregon",'PA'=>"Pennsylvania",'RI'=>"Rhode Island",'SC'=>"South Carolina",'SD'=>"South Dakota",'TN'=>"Tennessee",'TX'=>"Texas",'UT'=>"Utah",'VT'=>"Vermont",'VA'=>"Virginia",'WA'=>"Washington",'WV'=>"West Virginia",'WI'=>"Wisconsin",'WY'=>"Wyoming"); function showOptionsDrop($array){ $string = ''; foreach($array as $k => $v){ $string .= '<option value="'.$k.'"'.$s.'>'.$v.'</option>'."\n"; } return $string; } ?> <form> <select name="states"> <option value="0">Choose a state</option> <?php echo showOptionsDrop($states_arr); ?> </select> </form> I would like to show all the towns/zipcodes for each individual state with an "onchange" from the SELECT menu. The table is called "zip_codes" and the City/Zip Codes are called "city" and "zip" What I would like to do is display them as links, so a user can click into each town and either create a new entry (a restaurant) or update an existing entry. What would be the best approach for this? I appreciate the help. I've put together a very simple form & processing script for my site.. Everything works great except the body of the email i receive when the form is submitted contains everything but the info that has been entered into the fields. I'm sure it's something simple that I'm overlooked, but I'm officially stumped. What am I doing wrong here? <?php $mymail = 'ordietryingodt@yahoo.com'; $cc = 'New Recruit To Add!'; $BoDy = ' '; $FrOm = 'FROM:' .$_POST['t1']; $FrOm .= 'Reply-To:' .$_POST['t1']; $FrOm .= 'X-MAILER: PHP'.phpversion(); $BoDy .= 'Quake Live Name: '; $BoDy .= $_POST['t1']; $BoDy .= "\n"; $BoDy .= 'Age: '; $BoDy .= $_POST['t2']; $BoDy .= "\n"; $BoDy .= 'Residing Country: '; $BoDy .= $_POST['t3']; $BoDy .= "\n"; $BoDy .= 'Favorite Game Type: '; $BoDy .= $_POST['t4']; $BoDy .= "\n"; $send = mail("$mymail", "$cc", "$BoDy", "$FrOm"); if($send) { echo '<html><head>'; echo '<meta http-equiv="refresh" content="0;URL=/submitted.htm">'; echo '</head><body>Email send....'; echo '</body></html>'; } ?> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=325313.0 I am pretty new to PHP and am trying to create a simple (so I assumed) page to takes data from one html page(works fine) and updates a MYSQL Database. I am getting no error message, but the connect string down to the end of the body section is showing up as plain text in my browser window. I do not know how to correct this. I have tried using two different types of connect strings and have verified my names from the HTML page are the same as listed within the php page. Suggestions on what I need to look for to correct would be great. I have looked online, but so far all I am getting is how to connect, or how to create a comment, so I thought I would try here. Thank you for any assistance I may get!! - Amy - Code: [Select] <body><font color="006600"> <div style="background-color:#f9f9dd;"> <fieldset> <h1>Asset Entry Results</h1> <?php // create short variable names $tag=$_POST['tag']; $serial=$_POST['serial']; $category=$_POST['category']; $status=$_POST['status']; $branch=$_POST['branch']; $comments=$_POST['comments']; if (!$tag || !$serial || !$category || !$status || !$branch) { echo "You have not entered all the required details.<br />" ."Please go back and try again."; exit; } if (!get_magic_quotes_gpc()) { $tag = addslashes($tag); $serial = addslashes($serial); $category = addslashes($category); $status = addslashes($status); $branch = addslashes($branch); $comments = addslashes($comments); } //@ $db = new mysqli('localhost', 'id', 'pw', 'inventory'); $db = DBI->connect("dbi:mysql:inventory:localhost","id","pw") or die("couldnt connect to database"); $query = "insert into assets values ('".$serial."', '".$tag."', '".$branch."', '".$status."', '".$category."', '".$comments."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." asset inserted into Inventory."; } else { echo "An error has occurred. The item was not added."; } $db->close(); ?> </fieldset> </div> </body> Am new here - looks like a great foru! I would sincerely appreciate any help anyone can give me. I have been trying to solve my problem for hours and I am not having any luck, so I thought I would post and see if anyone can help. I am very stuck and am not making much progress on this project, and I am certain the answer is very simple. I am constructing a form to collect data for a specialized purpose. The form and program actually work for its intended function, but I am trying to enhance the user experience by preventing customers from having to reenter all of their data should there be a problem with any of the data submitted. I have been able to do that with the contact form portion, but what I am having trouble with is the portion which has as many as 400 possible entries. So, in a nutshell, if the customers contact data is incomplete or in error, the form will ask them to return to the page and correct things. The previous data entered has been saved in the session and the input value will equal the previous entry. i.e. <tr> <td align="right" class="infoBox"><?php echo ENTRY_EMAIL_ADDRESS; ?></td> <td align=left><?php echo "<input type=text name='cemail' value=\"$cemail\" size=35 maxlength=35>" ?></td> </tr> Works perfectly, all well and good there. On the other 400 more or less entries, I am having a difficult time tweaking the string concatenation to work to achieve similar results. There are 4 columns each with $points entries asking for a dimension in either feet or inches. The <input name=> is one of ptaf,ptai,ptbf,ptbi, appended programatically with the corresponding row number or data point. i.e. "ptaf1", "ptai1", etc... This is produced by the example below and works perfectly also. <?php { $points=100; $i=1; while ($i <= $points) {echo ' <tr><td align="center" width="6"><b> ' .$i . '</b></td> <td align="right" NOWRAP>A' .$i . ' (ft) <input type="text" name="ptaf'.$i.'" size=4 maxlength=3> </td> <td align="right" NOWRAP>A' .$i . ' (in) <input type="text" name="ptai'.$i.'" size=4 maxlength=4> </td> <td align="right" NOWRAP>B' .$i . ' (ft) <input type="text" name="ptbf'.$i.'" size=4 maxlength=3> </td> <td align="right" NOWRAP>B' .$i . ' (in) <input type="text" name="ptbi'.$i.'" size=4 maxlength=4> </td> '; $i++; } } ?> I am trying to add <input value=$ptai.$i> for each field but as I mentioned I am not having any luck. It seems as if I have tried every combination imagineable, but still no luck. My head is spinning! The closest I seem to have gotten was with this: <td align="right" NOWRAP>A' .$i . ' (ft) <input type="text" size=6 maxlength=3 name="ptaf'.$i.'" value="' . "$ptaf" . $i . '" ></td> But line 17 for example returns this: <input type="text" value="17" name="ptaf17" maxlength="3" size="6"> To recap, I am trying to have the value set to whatever the customer may have entered previously. Again, I would most appreciate any help anyone can give me. If you need clarification on anything please let me know. Thanks AJ Hello to all, I have problem figuring out how to properly display data fetched from MySQL database in a HTML table. In the below example I am using two while loops, where the second one is nested inside first one, that check two different expressions fetching data from tables found in a MySQL database. The second expression compares the two tables IDs and after their match it displays the email of the account holder in each column in the HTML table. The main problem is that the 'email' row is displayed properly while its while expression is not nested and alone(meaning the other data is omitted or commented out), but either nested or neighbored to the first while loop, it is displayed horizontally and the other data ('validity', 'valid_from', 'valid_to') is not displayed.'
Can someone help me on this, I guess the problem lies in the while loop? <thead> <tr> <th data-column-id="id" data-type="numeric">ID</th> <th data-column-id="email">Subscriber's Email</th> <th data-column-id="validity">Validity</th> <th data-column-id="valid_from">Valid From</th> <th data-column-id="valid_to">Valid To</th> </tr> </thead> Here is part of the PHP code:
<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo ' <tr> <td>'.$row["id"].'</td> '; while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) { echo ' <td>'.$row1["email"].'</td> '; } if($row["validity"] == 1) { echo '<td>'.$row["validity"].' month</td>'; }else{ echo '<td>'.$row["validity"].' months</td>'; } echo ' <td>'.$row["valid_from"].'</td> <td>'.$row["valid_to"].'</td> </tr>'; } ?>
Thank you. Hi, after banging my head against the wall for a while thinking this would be a simple task, I'm discovering that this is more complicated than I thought. Basically what I have is a link table linking together source_id and subject_id. For each subject there are multiple sources associated with each. I had created a basic listing of sources by subject... no problem. I now need a way of having a form to create an ordered list in a user-specified way. In other words, I can currently order by id or alphabetically (subject name lives on a different table), but I need the option of choosing the order in which they display. I added another row to this table called order_by. No problem again, and I can manage all of this in the database, however I want to create a basic form where I can view sources by subject and then enter a number that I can use for sorting. I started off looping through each of the entries and the database (with a where), and creating a foreach like so (with the subject_id being grabbed via GET from the URL on a previous script) Code: [Select] while($row = mysqli_fetch_array($rs)) { //update row order if (isset($_POST['submit'])) { //get variables, and assign order $subject_id = $_GET['subject_id']; $order_by = $_POST['order_by']; $source_id = $row['source_id']; //echo 'Order by entered as ' . $order_by . '<br />'; foreach ($_POST['order_by'] as $order_by) { $qorder = "UPDATE source_subject set order_by = '$order_by' WHERE source_id = '$source_id' AND subject_id = '$subject_id'"; mysqli_query($dbc, $qorder) or die ('could not insert order'); // echo $subject_id . ', ' . $order_by . ', ' . $source_id; // echo '<br />'; } } else { $subject_id = $_GET['subject_id']; $order_by = $row['order_by']; $source_id = $row['source_id']; } And have the line in the form like so: Code: [Select] echo '<input type="text" id="order_by" name="order_by[]" size="1" value="'. $order_by .'"/> (yes I know I didn't escape the input field... it's all stored in an htaccess protected directory; I will clean it up later once I get it to work) This, of course, results in every source_id getting the same "order_by" no matter what I put into each field. I'm thinking that I need to do some sort of foreach where I go through foreach source_id and have it update the "order_by" field for each one, but I must admit I'm not sure how to go about this (the flaws of being self-taught I suppose; I don't have anyone to go to on this). I'm hoping someone here can help? Thanks a ton in advance Here's the code that deals with the client side:
<?php session_start(); if(!isset($_SESSION['Logged_in'])){ header("Location: /page.php?page=login"); } ?> <!DOCTYPE Html> <html> <head> <!--Connections made and head included--> <?php require_once("../INC/head.php"); ?> <?php require_once("../Scripts/DB/connect.php"); ?> <!--Asynchronously Return User Names--> <script> $(document).ready(function(){ function search(){ var textboxvalue = $('input[name=search]').val(); $.ajax( { type: "GET", url: 'search.php', data: {Search: textboxvalue}, success: function(result) { $("#results").html(result); } }); }; </script> </head> <body> <div id="header-wrapper"> <?php include_once("../INC/nav2.php"); ?> </div> <div id="content"> <h1 style="color: red; text-align: center;">Member Directory</h1> <form onsubmit="search()"> <label for="search">Search for User:</label> <input type="text" size="70px" id="search" name="search"> </form> <a href="index.php?do=">Show All Users</a>|<a href="index.php?do=ONLINE">Show All Online Users</a> <div id="results"> <!--Results will be returned HERE!--> </div>search.php <?php //testing if data is sent ok echo "<h1>Hello</h1><br>" . $_GET['search']; ?>This is the link I get after sending foo. http://www.family-li...php?&search=foo Is that mean it was sent, but I'm not processing it correctly? I'm new to the whole AJAX thing. This could be PHP or MySql so putting it in PHP forum for now... I have code below (last code listed) which processes a dynamically created Form which could have anywhere from 0 to 6 fields. So I clean all fields whether they were posted or not and then I update the mySQL table. The problem with this code below is that if, say, $cextra was not posted (i.e. it wasnt on the dynamically created form), then this code would enter a blank into the table for $cextra (i.e. if there was already a value in the table for $cextra, it gets overwritten, which is bad). What is the best way to handle this? I'm thinking i have to break my SQL query into a bunch of if/else statements like this... Code: [Select] $sql = "UPDATE cluesanswers SET "; if (isset($_POST['ctext'])){ echo "ctext='$ctext',"; } else { //do nothing } and so on 5 more times.... That seems horribly hackish/inefficient. Is there a better way? Code: [Select] if (isset($_POST['hidden']) && $_POST['hidden'] == "edit") { $cimage=trim(mysql_prep($_POST['cimage'])); $ctext=trim(mysql_prep($_POST['ctext'])); $cextra=trim(mysql_prep($_POST['cextra'])); $atext=trim(mysql_prep($_POST['atext'])); $aextra=trim(mysql_prep($_POST['aextra'])); $aimage=trim(mysql_prep($_POST['aimage'])); //update the answer edits $sql = "UPDATE cluesanswers SET ctext='$ctext', cextra='$cextra', cimage='$cimage', atext='$atext', aextra='$aextra', aimage='$aimage'"; $result = mysql_query($sql, $connection); if (!$result) { die("Database query failed: " . mysql_error()); } else { } I have two tables. Table Name:Users Fields: User_name user_email user_level pwd 2.Reference Fields: refid username origin destination user_name in the users table and the username field in reference fields are common fields. There is user order form.whenever an user places an order, refid field in reference table will be updated.So the user will be provided with an refid Steps: 1.User needs to log in with a valid user id and pwd 2.Once logged in, there will be search, where the user will input the refid which has been provided to him during the time of order placement. 3.Now User is able to view all the details for any refid 3.Up to this we have completed. Query: Now we need to retrieve the details based on the user logged in. For eg: user 'USER A' has been provided with the referenceid '1234' during the time of order placement user 'USER B' has been provided with the referenceid '2468' during the time of order placement When the userA login and enter the refid as '2468' he should not get any details.He should get details only for the reference ids which is assigned to him. <?php session_start(); if (!$_SESSION["user_name"]) { // User not logged in, redirect to login page Header("Location: login.php"); } $con = mysql_connect('localhost','root',''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); $user_name = $_POST['user_name']; $refid = $_POST['refid']; $query = "SELECT * from reference,users WHERE reference.username=users.user_name AND reference.refid='$refid' AND "; $result = mysql_query($query) or trigger_error('MySQL encountered a problem<br />Error: ' . mysql_error() . '<br />Query: ' . $query); while($row = mysql_fetch_array($result)) { echo $row['refid']; echo $row['origin']; echo $row['dest']; echo $row['date']; echo $row['exdate']; echo $row['username']; } echo "<p><a href=\"logout.php\">Click here to logout!</a></p>"; ?> <html> <form method="post" action="final.php"> Ref Id:<input type="text" name="refid"> <input type="submit" value="submit" name="submit"> </html> Say there is a complex opt in process where people start to enter their data but certain questions stop them where they close out of the page. They already entered their data and I feel there is a way to grab it and post it to mysql even though they do not click submit.
How would this be done?
A super simple example (proof of concept) or a link to a tutorial would be very useful.
Edited by brentman, 23 September 2014 - 10:42 AM. Hi, I've currently started to modify a chat script of mine to output a moderation panel but the moderation page seems empty(blank) every time I load it. What im trying to do is to take the ID part in my URL via the $_GET and look it up in my database table in the column named id, then select that specific row to be able to retrieve the StringyChat_ip and place it into another table to ban the IP and the second thing im trying to do is to be able to delete the specific row from my table.
My Http link look something like
http://imagecrab.fre.../ban.php?id=159
and my ban.php page where I want to lookup the 159 part and do the banning etc looks like
<? include("admin_code_header.php"); if ($_POST["DeletePost"]) { $id = $_POST['id']; $query = "DELETE FROM ".$dbTable." WHERE id='".$id."'"; mysql_query($query); echo "ID removed from system: ".$id; } if ($_POST["BanIP"]) { $IP_To_Add = $_POST["ip"]; $sql = "INSERT INTO ".$IPBanTable." (ip) VALUES (\"$IP_To_Add\")"; $result = mysql_query($sql); } $result = mysql_query("SELECT * FROM ".$dbTable." WHERE id='".$id."'",$db); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; $idm = $myrow["id"]; ?> <html> <form name="form<? echo $myrow["id"];?>" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input name="DeletePost" type="submit" id="DeletePost" value="Delete"> <input name="BanIP" type="submit" id="BanIP" value="Ban <? echo $myrow["StringyChat_ip"];?>"> </form> </html> <? } ?> I can add and delete data from my table. Now I need to be able to change one or more fields in an entry. So I want to retrieve a row from the db, display that data on a form where the user can change any field and then pass the changed data to an update.php program. I know how to go from form to php. But how do I pass the data from retrieve.php to a form so it will display? Do I use a URL and Get? Can I put the retrieve and form in the same program? Hi, I want to pull data from db, where sometimes all rows and sometimes rows matching given "username". Here is my code:
//Grab Username of who's Browsing History needs to be searched. if (isset($_GET['followee_username']) && !empty($_GET['followee_username'])) { $followee_username = $_GET['followee_username']; if($followee_username != "followee_all" OR "Followee_All") { $query = "SELECT * FROM browsing_histories WHERE username = \"$followee_username\""; $query_type = "followee_username"; $followed_word = "$followee_username"; $follower_username = "$user"; echo "$followee_username"; } else { $query = "SELECT * FROM browsing_histories"; $query_type = "followee_all"; $followed_word = "followee_all"; $follower_username = "$user"; echo "all"; } }
When I specify a "username" in the query via the url: browsing_histories_v1.php?followee_username=requinix&page_number=1 I see result as I should. So far so good.
Now, when I specify "all" as username then I see no results. Why ? All records from the tbl should be pulled! browsing_histories_v1.php?followee_username=all&page_number=1 This query shouldv'e worked:
$query = "SELECT * FROM browsing_histories";
|