PHP - How To Pass Php Variable To Google Charts?
my value, selectname.push(element.name); selectqty.push(element.qty); How to pass Google charts function,
$.each(data, function(index, element) { selectname.push(element.name); selectqty.push(element.qty); google.charts.load('current', { 'packages': ['corechart'] }); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data1 = google.visualization.arrayToDataTable([ ['Task', 'Hours per Day'], ['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7] ]); // var data1 = google.visualization.arrayToDataTable([ // [element.name, element.qty], // // // ]); var options = { title: 'Top 5 Best Selling Products' }; var chart = new google.visualization.PieChart(document.getElementById('piechart')); chart.draw(data1, options); }
Similar TutorialsHi
I am trying to create a google chart from data in query.php and using the google api to load it. Everything works until I want to change the MetalSourceID from a drop select box.
PHP CODE FOR DROP DOWN BOX:
<form> <select name="users" onchange="showUser(this.value);drawChart();"> <option value=""> Select a Metal: </option> <?php $query = "SELECT TOP(31) tblMetalPrice.MetalSourceID, tblMetalSource.MetalSourceName from tblMetalPrice INNER JOIN tblMetalSource ON tblMetalPrice.MetalSourceID=tblMetalSource.MetalSourceID ORDER BY tblMetalPrice.DateCreated DESC "; $result = sqlsrv_query( $conn, $query); while( $row = sqlsrv_fetch_object ($result)) { echo "<option value='".$row->MetalSourceID ."'>". $row->MetalSourceName ."</option>"; } sqlsrv_close( $conn); ?> </select> </form>This works fine and generates all the correct values. One part of this changes contents of a table which works fine. But I also echo the MetalSourceID into the javascript for the google api, JS script below: <script type="text/javascript"> google.load('visualization', '1', {'packages':['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var jsonData = $.ajax({ url: "query.php", dataType:"json", async: false, data: { 'MetalSourceID' : <?php $q = intval($_GET['q']); echo $q; ?> } }).responseText; var data = new google.visualization.DataTable(jsonData); var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data); } </script>This then runs the query.php script and returns the google line chart, a copy of the query.php script is below: My wife is a Type 1 diabetic and I am trying to put a site together where she can record her blood/glucose readings and analyse the readings.
I am trying to use Google Charts to create a line graph so that she can see if their is a trend during the day when her blood sugar levels peak and trough. But my coding isn't providing any results.
Can anyone see what I am doing wrong?
<?php $level=DB::getInstance()->query("SELECT * FROM tabbyhealth WHERE reading!=0"); foreach ($level->results() as $levelresults) $glucose = $levelresults->reading; $timestamp = date('d M Y h.i A',strtotime($levelresults->timestamp) +18000); ?> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1.0', {'packages':['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Time of Reading'); data.addColumn('number', 'Blood Glucose Reading'); data.addRows([ ['<?php echo $timestamp; ?>', '<?php echo $glucose; ?>'] ]); var options = { title:'Blood Glucose Monitoring', curveType: 'function', legend: { position: 'bottom' } width:600, height:300 hAxis: { title: 'Date/Time' }, vAxis: { title: 'Reading' } }; var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> </head> <body> <div id="chart_div"></div> </body>I have even tried replacing data.addRows([ ['<?php echo $timestamp; ?>', '<?php echo $glucose; ?>'] ]);with data.addRows([ [0, 0, 0], [1, 10, 5], [2, 23, 15], [3, 17, 9], [4, 18, 10], [5, 9, 5], [6, 11, 3], [7, 27, 19], [8, 33, 25] ]);to see if it is just a problem with reading from my database, but I am still getting nothing - by nothing I mean that no chart is appearing. Hello, I am new to pHp and javascript languages and I am trying to do some math calculations in pHp, then display the results with google charts. However, I got stuck with inserting data from pHp using json_encode. It works for the most simple array, with using 2 values. When using array of arrays, it does not work. I believe it could be a syntax errors with all those brackets but I could not figure it out. Thanks for any ideas! <?php // some arrays with dim 2x2 $testarr0 = array( 0.1, 2.5); $testarr = array( 1.0, 3.5); $testarr = array( $testarr0, $testarr ) ; // this is how it looks in pHp $json = json_encode($testarr); echo($json); echo '<br/>'; echo json_encode($json); ?> <html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"> </script> <script type="text/javascript"> google.charts.load('current', {'packages':['line']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('number', 'x values'); data.addColumn('number', 'y1 '); //var dataArray = <?php echo json_encode($testarr);?>; //document.body.innerHTML = " Data Array with json: " + dataArray ; // defining array here works well /* data.addRows( [ [0.1 ,2.5], [1.0 ,3.5] ] ); */ // this here does not work: data.addRow( <?php echo json_encode($testarr);?> ); // some options for the chart var options = { chart: { title: 'Points over time', }, width: 600, height: 400, axes: { x: { 0: {side: 'top'} } } }; var chart = new google.charts.Line(document.getElementById('line_top_x')); chart.draw(data, google.charts.Line.convertOptions(options)); } </script> </head> <body> <div id="line_top_x" style="width: 900px; height: 500px"></div> </body> </html>
Good morning,
I am doing a small project including google charts API but I am having trouble getting my results into the json format that is required.
Google's documentation states the json format should be:
{ "cols": [ {"id":"","label":"Topping","pattern":"","type":"string"}, {"id":"","label":"Slices","pattern":"","type":"number"} ], "rows": [ {"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]}, {"c":[{"v":"Onions","f":null},{"v":1,"f":null}]}, {"c":[{"v":"Olives","f":null},{"v":1,"f":null}]}, {"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]}, {"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]} ] }the query works perfectly fine thats not the problem but getting it into the above format is proving hard than I expected. The below is what I am trying to do to populate the json data in the correct format. function graphdata() { $array['cols'][] = array('type' => 'string'); $array['cols'][] = array('type' => 'string'); $array['cols'][] = array('type' => 'string'); $result = sqlsrv_query($conn, $query); while($row = sqlsrv_fetch_object($result)){ $array['rows'][] = array('c' => array( array('v'=>'$row->DateCreated->format('d-m-Y')'), array('v'=>$row->UnitPrice)) ); } return $array; } print json_encode(graphdata());I am using MSSQL and not the normal mysql hence the above code, i am a starter when it comes to php so I may be doing something basic totally wrong but I cannot seem to get it to work. Thanks Hi, Ihave the below array output from a DB query. I need to convert into the bottom array for Google CHarts. Any ideas? $myarray = array( 0 => array( 'year' => 2009, 'month' => "January", 'month_sales' => 524, 'year_totalsales' => 3610 ), 1 => array ( 'year' => 2009, 'month' => 'February', 'month_sales' => 521, 'year_totalsales' => 3610 ), 2 => array ( 'year' => 2009, 'month' => 'March', 'month_sales' => 501, 'year_totalsales' => 3610 ), 3 => array ( 'year' => 2009, 'month' => 'April', 'month_sales' => 601, 'year_totalsales' => 3610 ), 4 => array ( 'year' => 2009, 'month' => 'May', 'month_sales' => 710, 'year_totalsales' => 3610 ), 5 => array ( 'year' => 2009, 'month' => 'June', 'month_sales' => 801, 'year_totalsales' => 3610 ), 6 => array ( 'year' => 2009, 'month' => 'July', 'month_sales' => 991, 'year_totalsales' => 3610 ), 7 => array ( 'year' => 2009, 'month' => 'August', 'month_sales' => 301, 'year_totalsales' => 3610 ), 8 => array ( 'year' => 2009, 'month' => 'September', 'month_sales' => 250, 'year_totalsales' => 3610 ), 9 => array ( 'year' => 2009, 'month' => 'October', 'month_sales' => 322, 'year_totalsales' => 3610 ), 10 => array ( 'year' => 2009, 'month' => 'November', 'month_sales' => 621, 'year_totalsales' => 3610 ), 11 => array ( 'year' => 2009, 'month' => 'December', 'month_sales' => 691, 'year_totalsales' => 3610 ), 12 => array ( 'year' => 2010, 'month' => "January", 'month_sales' => 789, 'year_totalsales' => 1610 ), 13 => array ( 'year' => 2010, 'month' => "February", 'month_sales' => 1409, 'year_totalsales' => 1610 ), 14 => array ( 'year' => 2010, 'month' => "March", 'month_sales' => 550, 'year_totalsales' => 1610 ) ); raw_data=[['January',524,0],['February',521,0],['March',501,0],['April',601,0],['May',710,0],['June',801,0], ['July',991,0],['August',301,0],['September',250,0],['October',322,0],['November',621,0],['December',691,0],['January',789,0],['February',1409,0],['March',550,0],]; raw_data= [ [ month1 , year1 sales figure(zero if no figure), year2 sales figure(zero if no figure).....], [ month1 , year1 sales figure(zero if no figure), year2 sales figure(zero if no figure).....]......]; Thanks all i've to populate google charts with dynamic data. the data looks llike. +----+-------+---------+-------+-----------+---------+------+ | id | name | physics | maths | chemistry | biology | sst | +----+-------+---------+-------+-----------+---------+------+ | 1 | Name1 | 10 | 25 | 35 | 42 | 62 | | 2 | Name2 | 80 | 45 | 45 | 45 | 25 | | 3 | Name3 | 63 | 25 | 63 | 36 | 36 | | 4 | Name4 | 82 | 36 | 75 | 48 | 42 | | 5 | Name5 | 45 | 45 | 78 | 25 | 24 | | 6 | Name6 | 36 | 36 | 15 | 75 | 36 | | 7 | Name7 | 99 | 45 | 24 | 24 | 45 | | 8 | Name8 | 45 | 85 | 85 | 85 | 96 | +----+-------+---------+-------+-----------+---------+------+ i have to create google charts based on this such that # namewise - such that when i select a name it displays all subject marks of that particular name in a column chart #markswise - when i select a subject, it displays all the names with marks in that particular subject. conisdiering that data may be added and i've to accumulate that also, for namewise i did // chart.php <?php include("connection.php"); $query = "SELECT name FROM csv GROUP BY name DESC"; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); ?> <!DOCTYPE html> <html> <head> <title>Google charts</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> </head> <body> <br /><br /> <div class="container"> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <div class="col-md-9"> <h3 class="panel-title">Student Wise Marks Data</h3> </div> <div class="col-md-3"> <select name="name" class="form-control" id="name"> <option value="">Select Student</option> <?php foreach($result as $row) { echo '<option value="'.$row["name"].'">'.$row["name"].'</option>'; } ?> </select> </div> </div> </div> <div class="panel-body"> <div id="chart_area" style="width: 1000px; height: 620px;"></div> </div> </div> </div> </body> </html> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {packages: ['corechart', 'bar']}); google.charts.setOnLoadCallback(); function load_student_data(name, title) { var temp_title = title + ' '+name+''; $.ajax({ url:"fetch.php", method:"POST", data:{name:name}, dataType:"JSON", success:function(data) { drawStudentwiseChart(data, temp_title); } }); } function drawStudentwiseChart(chart_data, chart_main_title) { var jsonData = chart_data; var data = new google.visualization.DataTable(); data.addColumn('number', 'Physics'); data.addColumn('number', 'Maths'); data.addColumn('number', 'Chemistry'); data.addColumn('number', 'Biology'); data.addColumn('number', 'SST'); $.each(jsonData, function(i, jsonData){ var Physics = jsonData.Physics; var Maths = jsonData.Maths; var Chemistry = jsonData.Chemistry; var Biology = jsonData.Biology; var SST = jsonData.SST; data.addRows([[Physics,Maths,Chemistry,Biology,SST]]); }); var options = { title:chart_main_title, hAxis: { title: "Subjects" }, vAxis: { title: 'Percentage' } }; var chart = new google.visualization.ColumnChart(document.getElementById('chart_area')); chart.draw(data, options); } </script> <script> $(document).ready(function(){ $('#name').change(function(){ var name = $(this).val(); if(name != '') { load_student_data(name, 'Student wise marks data'); } }); }); </script> and in order to fetch data // fetch.php <?php //fetch.php include('connection.php'); if(isset($_POST["name"])) { $query = " SELECT * FROM csv WHERE name = '".$_POST["name"]."' ORDER BY id ASC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { $output[] = array( 'Physics' => $row["Physics"], 'Maths' => $row["Maths"], 'Chemistry' => $row["Chemistry"], 'Biology' => $row["Biology"], 'SST' => $row["SST"], ); } echo json_encode($output); } ?> it diplays a blank page. however when i play with singular values i.e one subject at a time it displays fine Edited March 19, 2019 by zetastreakHi guys, I need your help, I have got a problem with the if statement. When I don't insert the pass function in the url like this: Code: [Select] http://www.mysite.com/myscript.php?image=myimagelocation&strings=mystrings&user=test I will get this on my php page: Code: [Select] PASSWORD are missing Code: [Select] <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbusername'); define('DB_PASSWORD', 'mydbpass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $image = clean($_GET['image']); $strings = clean($_GET['strings']); $username = clean($_GET['user']); $pass = clean($_GET['pass']); if($username == '' && $pass) { $errmsg_arr[] = 'username are missing'; $errflag = true; }elseif($username && $pass =='') { $errmsg_arr[] = 'PASSWORD are missing'; $errflag = true; } if($username == '' && $pass == '') { $errmsg_arr[] = 'username or password missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['image'])) { $insert[] = 'image = \'' . clean($_GET['image']) . '\''; } if(isset($_GET['strings'])) { $insert[] = 'strings = \'' . clean($_GET['strings']) . '\''; } if(isset($_GET['user'])) { $insert[] = 'user = \'' . clean($_GET['user']) .'\''; } if(isset($_GET['pass'])) { $insert[] = 'pass = \'' . clean($_GET['pass']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); $required_fields = array('image', 'strings', 'user'); if($image && $strings && $username) { echo "working 1"; } elseif($username && $pass) { echo "working 2"; } } } ?> Do anyone know how to fix this? Hello
I'm using a form to collect user data (is a Cognito form) it is displayed on vacation rental properties pages, so it collects user´s email, in date, out date, etc. in the cognito form I have one text hidden field called REF, I wonder how to do in order to use the same form and be able to identify where the info comes from. I thougt that if I could put the page url into the REF variable, the problem would be solved, but I'm not sure if that is possible and how to do it. It is? If not: is it possible to handle that ? I have researched all over forums from past day. Not getting correct solution. I have 2 textboxes and a button. First box is to enter value and i will click button, i need to get the value.
Here is the code, that works without input box 1
In this code i want to modify my web address, at the end after ky= i want add my first textbox value, then click event and output in second textbox, let me know where i messed.
<script type="text/javascript"> function Assign() { <?php $html = file_get_contents("http://geoportaal.maaamet.ee/url/xgis-ky.php?ky=79401:006:0812" ); preg_match_all('(<li.*?>.*?</li>)', $html, $matches); $one=$matches[0][0]; ?> document.getElementById("OutputField").value = "<?=$one?>"; } </script> <input id="InputField" type="text" style="width:200px"/> <input type="submit" value="Assign Value" onclick="Assign()"/> <input id="OutputField" type="text" style="width:200px"/> so I need some help passing these variable from this page to final.php. how do I pass these arrays? I know if it were singled....not arrayed, I could use hidden fields in a form and echo them out....but these are multiples....not singled. The form way is prefered.....but it doesn't have to be. I just need these passed to the page where I am going to process them. I am not good at working with arrays. Thanks in advance Code: [Select] <?php include_once("connect.php"); session_start(); foreach($_POST["product"] AS $key => $val) { $product = $val; $month = $_POST['month'][$key]; $day = $_POST['day'][$key]; $year = $_POST['year'][$key]; $date = $_POST['date'][$key]; $price = $_POST['price'][$key]; $qty = $_POST['qty'][$key]; $id = $_POST['id'][$key]; $total = $_POST['total'][$key]; $academy = $_POST['academy'][$key]; $priceunit = $price * $qty; } ?> When i execute the following code, it works and retrieves the record info i am looking for for the appropriate record, 2155015898: $adgrouppass = 2155015898; $selector->adGroupIds = array($adgrouppass); However, when i try to get the adgroup variable from my url, which is where it is located, it doesn't work: $adgroup = trim($_GET['adgroup']); $adgrouppass = $adgroup; $selector->adGroupIds = array($adgrouppass); yet, in trying to fix it, if i echo the above variable, it says it is correct, which is 2155015898. Not sure if the $adgrouppass needs to be a string or variable to get it to pass it correctly. Can anyone help? Hi, I have this script, it all works fine apart from when I pass the variable on, it only passes the first word and not the whole variable The form that actions to the samples page passes the $siteName as My Test Site, if I type echo $siteName in the sameples page, it will print My Test Site, however when I use this Code: [Select] createSample&siteName=$siteName to pass the variable to the next page, it just echos 'My' instead of My Test Site. Even when I scroll over the link above it just shows My in the url. Code: [Select] case "samples": // Get submitted data and assign to variables $siteName = $_POST['siteName']; $adminEmail = $_POST['adminEmail']; $sendmailLoc = $_POST['sendmailLoc']; $imgdir = $_POST['imgdir']; $imgdirbase = $_POST['imgdirbase']; // Write variable data to text file $FileName = "data/server.txt"; $FileHandle = fopen($FileName, 'w') or die("can't open file"); $data = "<?php\n\$siteName = '$siteName';\n?>"; fwrite($FileHandle, $data); $data = "<?php\n\$adminEmail = '$adminEmail';\n?>"; fwrite($FileHandle, $data); $data = "<?php\n\$sendmailLoc = '$sendmailLoc';\n?>"; fwrite($FileHandle, $data); $data = "<?php\n\$imgdir = '$imgdir';\n?>"; fwrite($FileHandle, $data); $data = "<?php\n\$imgdirbase = '$imgdirbase';\n?>"; fwrite($FileHandle, $data); fclose($FileHandle); // Displays the create sample pages page ECHO <<<SAMPLES <table border=0 align=center bgcolor=#00CCFF> <tr> <td><span class=style1><b><center>Create Sample Pages</center></b></span></td> </tr> <tr> <td>Would you like Member Site Maker to create sample pages for: <ul> <li>index.html</li> <li>login.html</li> <li>search.html</li> <li>register.html</li> </ul> </td> </tr> <tr> <td><a href=installation.php?cmd=createSample&siteName=$siteName>Yes</a> </td> <td><a href=installation.php?cmd=mysql>No</a> </td> </tr> </table> SAMPLES; break; Can anybody tell me where I am going wrong please? Thanks Can someone explain to me how this is done? Hi All, I have a function that i want to pass a variable into so that i can do some SQL on it. The information that i want to pass into it is a data-id on a button that is used to trigger the function. The button that will be clicked is this <div class='modaltrigger btn btn-primary' data-id='$itemId' data-toggle='modal'>Manage</div> This button is being created by another function. I would like to know either how i pass the variable from one function to another or how i pass it from the data-id to the function in php. Thanks in advance. Hi, Im trying to pass a variable ($in_this_instance) into, and then back out of a function. The variable goes into the function no problem, and is echo'ed out fine. However the echo after the close of the function, does not give anything out. Code: [Select] $in_this_instance = 'boo'; function in_this_instance($data) { global $in_this_instance; echo $in_this_instance; $in_this_instance = 'hoo'; $rep_val = '[front banner]'; $test = strpos($data, $rep_val); if ($test === false) { return $data; } else { return $data;; } } add_filter('the_content', 'in_this_instance'); echo $in_this_instance; Could any one give me a pointer please? Many Thanks! Hi guys, I have a trouble with my php snippet, when I insert the var function in the url bar something is like: http://www.mysite.com/delete.php?favorites&id=0 or http://www.mysite.com/delete.php?whateveritis&id=0 It doesn't get pass the favorites function to delete the id. It is the same things that it goes for each different function. Here's the current code: <?php Code: [Select] session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'mydbuser'); define('DB_PASSWORD', 'mydbpass'); define('DB_DATABASE', 'mydbtablename'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $favorites = clean($_GET['favorites']); $id = clean($_GET['id']); if($favorites && $id == ''){ // both are empty $errmsg_arr[] = 'favorites id are missing.'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['id'])) { $insert[] = 'id = \'' . clean($_GET['id']) .'\''; } if(isset($_GET['favorites'])) { $insert[] = 'favorites = \'' . clean($_GET['favorites']) . '\''; } if($favorites && $id) { mysql_query("DELETE FROM favorites WHERE id='$id'"); $deleted = mysql_affected_rows(); if($deleted > 0) { echo "favorites channels is deleted"; } else { echo("favorites is already deleted"); } } } ?> If you do know how to get pass the favorites function, then please say so as i need your help. Any advice would be much appreicated. You guys are great, thanks again for the help last week. Now I almost got this working but a small hiccup. here is my code: Code: [Select] <?php include("config.php"); $my_t=getdate(date("U")); $my_t1=$my_t[weekday]; $result = mysql_query("SELECT * FROM tourney where day_of_week = '$my_t1'") or die(mysql_error()); if ($result == '') echo "<br>Empty Set\n"; print_r ($my_t1); This prints correctly Code: [Select] while ($result = mysql_fetch_array($result,MYSQL_ASSOC)) { This is my error. "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hermes/bosweb/web017/b172/ipg.dswdesignsnet/pp4c/charity1.php on line 8" Code: [Select] print "<b>Starting Time: <br></b>".$row{'start_time'}."<br><b>Tournament: </b><br>".$row{'tourney'}."<br><b>Buy-in: <br>".$row{'buy_in'}."<br><b>Starting Chips: <br>".$row{'start_chips'}."</font><p>"; This prints headers correctly, but no variables. Code: [Select] } mysql_close($dbh); ?> What did I forget to do or what did I do wrong. I'm still learning mysql and php. I have a table that has 5 columns Quote player_id fname lname team I'm trying to get all the values from that table using this sql command Code: [Select] include_once('../database_connection.php'); $player_id = addslashes($_REQUEST['edit_player']); $sql_query = "Select * from nba_info where player_id = '$player_id'"; $result = MYSQL_QUERY($sql_query); "edit_player" above is came from a different page. They I'm fetching the data using while Code: [Select] while($row = mysql_fetch_array($result)) { $row['player_id']; $row['fname']; $row['lname']; $row['team']; $row['email']; } Then I'm trying to pass that values to a variable here Code: [Select] $id = $row['player_id']; $fname = $row['fname']; $fname = $row['lname']; $lname = $row['team']; $email = $row['email']; When I'm trying to put that variables in a textbox value, they are not showing up Here Code: [Select] <table> <form name="edit_player_form" method="post" action=""> <tr> <td>Players ID</td> <td><input type="text" name="playerid" size="20" value="<?php echo $id; ?>" /></td> </tr> <tr> <td>First Name</td> <td><input type="text" name="fname" size="20" value="<?php echo $fname; ?>" /></td> </tr> <tr> <td>Last Name</td> <td><input type="text" name="lname" size="20" value="<?php echo $lname; ?>" /></td> </tr> <tr> <td>Team</td> <td><input type="text" name="team" size="20" value="<?php echo $team; ?>" /></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" size="20" value="<?php echo $email; ?>" /></td> </tr> <tr> <td><div align="center"> <input type="submit" name="Submit" value="Edit This Player"> </div></td> </tr> </form> </table> I wonder why it ain't showing up on the textbox value? tried almost everything... Anyone? Hello! I've got an issue! I'm trying to pass a very very long variable from JS to PHP through $_GET, but it seems too long for get. Is there any encryption function that works on both JS and PHP, so I can encrypt it in JS, send it though GET and decrypt it in PHP? Thanks ! I am passing the variable $searchno from form1.html using <form action="display1.php" method="post" Display1.php reads my database and displays the data. Now I want to link from the displayed page to display2.php and pass and capture the same variable $searchno. How do I do that? |