PHP - Html Table To Csv
Hi,
Have taken a look around and cannot find an answer to this one. I have the following page producing an HTML table http://www.weatherweb.net/weathertest.php I'd like the table to export (automatically) as a csv file. Is this possible, and if so how? With thanks, Simon Similar TutorialsHello, I need some help. Say that I have a list in my MySQL database that contains elements "A", "S", "C", "D" etc... Now, I want to generate an html table where these elements should be distributed in a random and unique way while leaving some entries of the table empty, see the picture below. But, I have no clue how to do this... Any hints? Thanks in advance, Vero I know I'm doing it something right, but can someone tell me why only one table is showing up? Can you help me fix the issue? Heres my code: function showcoords() { echo"J3st3r's CoordVision"; $result=dbquery("SELECT alliance, region, coordx, coordy FROM ".DB_COORDFUSION.""); dbarray($result); $fields_num = mysql_num_fields($result); echo "<table border='1'>"; // printing table headers echo "<td>Alliance</td>"; echo "<td>Region</td>"; echo "<td>Coord</td>"; // printing table rows while($row = mysql_fetch_array($result)) { // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row AS $Cell) echo "<tr>"; echo "<td>".$row['alliance']."</td>\n"; echo "<td>".$row['region']."</td>\n"; echo "<td>".$row['coordx'].",".$row['coordy']."</td>\n"; echo "</tr>\n"; } echo "</table>"; mysql_free_result($result); } I have 2 rows inserted into my coords table. Just frustrated and ignorant to php. Hello all is there any way to save a dynamic table to xls file as is? i mean the colors and all the style i use for the table. is there any function that do this? i found PHPExcel.... but i dont have the time or the power to start learn all the functions.... any simple class that do so? I have a table with x ammount of rows and x ammount of columns, in each TD there is an input box which the user fills in, when they press save the information is input into the database in this form at 6,1,2,3,4,5,6,A,1,2,3,4,5,6,B,1,2,3,4,5,6 - the first number is the number of columns, 1- 6 is the top line of TDs (column headers) and then A 1-6 is row 1, B 1-6 is row 2 etc.. so i then out put the information into a table via a for loop : Code: [Select] while($row = mysql_fetch_array($r)) { $data = explode(',',$row["content_bottom"]); $datacount = count($data); echo"<table border='1'><tr><td>Tool Type</td>"; $k = 1; for ($i = 1; $i <= $datacount; $i++) { if($data[$i] !=""){ echo "<td>".$data[$i]."</td>"; if($k == $data[0]-1) { echo"</tr><tr>"; $k = -1; } $k++; } } echo"</table>"; I can see how i would delete a row of information, eg delete B 1-6, but any ideas how I could delete a column? or is there a better way of storing this information? First the code: Code: [Select] <?php $columns = 4; $num_results = mysql_num_rows($result); $col_rows = intval($num_results / $columns); $count = 1; ?> <table cellspacing="2" class="tabela"> <tr> <td> <?php while ($row = mysql_fetch_array($result)) { $count = $count++; $title = $row["Rim"]; $model = $row["model"]; $dimenzija = $row["Dimenzija"]; $ime = $row['name']; echo "$model<br>$dimenzija<br>$ime" ; if ($count == $col_rows) { echo "</td>\n"; echo "<td>\n"; $count = 1; }} ?> </td> </tr> </table> (table is 100% width and td is 25%) Problem with this is that td will go in linear like structure. I want it after 4 td's to go into new row (something like <br> tag). How to do this? Also when their is one result, td is 100% width (it stretch across hole screen). How to define it to be 25% at all time? Afternoon Freaks, I'm trying to display the results of a MySQL query in an HTML table, unsuccessfully. The query returns six rows, but my HTML table only returns one (besides the header row). Here's the code: Code: [Select] </head> <table border="1"> <tr> <th>Fuel type</th> <th>Number of units</th> <th>Output</th> <th>Capability factor</th> <th>Pollution, in tons<sub>2</sub> emitted</th> </tr> <?php $db_hostname = "localhost"; $db_name = "dbname"; $db_username = "joeblow"; $db_password = "password"; $cxn = mysql_connect($db_hostname,$db_username,$db_password) or die ("Could not connect: " . mysql_error()); mysql_select_db($db_name); $sql = "SELECT output, fuel, numunits, capabilityfactor, pollution FROM db1 GROUP BY fuel ORDER BY sum(output) DESC"; $result = mysql_query($sql, $cxn) or die ("sorry, try again"); while ( $row = mysql_fetch_assoc($result)) { extract($row); $capfactor = number_format($capabilityfactor,2)*100; if ($fuel == "fuel1") $fuel1_total = $output; if ($fuel == "fuel2") {$fuel2_total = $output; $fuel2_pollution = $pollution;} if ($fuel == "fuel3") {$fuel3_total = $output; $fuel3_pollution = $pollution;} if ($fuel == "fuel4") $fuel4_total = $output; if ($fuel == "fuel5") $fuel5_total = $output; if ($fuel == "fuel6") {$fuel6_total = $output; $fuel6_pollution = $pollution;} $waste = number_format($pollution); } ?> <tr> <td><?php echo $fuel; ?></td> <td><?php echo $numunits; ?></td> <td><?php echo $foutput; ?></td> <td><?php echo $capfactor; ?></td> <td><?php echo $waste; ?></td> </tr> </table> <body> </body> </html> What I get is the html table with the right header row but the only data row is the one corresponding to fuel6. Something tells me the problem is with the positioning of the PHP tags, but I've tried all sorts of combinations and they usually produce an error that indicates I'm missing a curly bracket or the ?> tag. I'm stumped. Anybody have an idea what I'm doing wrong? <?php function money($amount,$separator=true,$simple=false){ return (true===$separator? (false===$simple? number_format($amount,2,'.',','): str_replace('.00','',money($amount)) ): (false===$simple? number_format($amount,2,'.',''): str_replace('.00','',money($amount,false)) ) ); } $income = 5000000000; $daily = money($income*24,true,true); $weekly = money(($income*24)*7,true,true); $monthly = money((($income*24)*7)*30,true,true); ?> </center> <center> <table border="1"> <tr> <td>Daily</td> <td><?php echo $daily ?></td> </tr> <tr> <td>Weekly</td> <td><?php echo $weekly ?></td> </tr> <tr> <td>Monthly</td> <td><?php echo $monthly ?></td> </tr> </table> </form> </center> What am I doing wrong? Im fairly new to this Hi guys, im trying to parse a html table from an existing website to my own. However ive run into a few problems. Does anyone know how to parse html tables?? im using the PHP DOM Parser but at the moment i am only able to return all the data on the website rather then the specific table. Thanks for any help! Hi, I'm a little bit new to php and I'm having some issues selecting some data from a mySQL database and fetching it into a fluid html table..... Basicly what I want is a table with 4 columns and a X number of rows depending on how much entry is stored in the DB. Here's the SELECT code : Code: [Select] <?php mysql_connect("host", "user", "pass") or die(mysql_error()); mysql_select_db("DB") or die(mysql_error()); $id = $_GET['id']; $data = mysql_query("SELECT * FROM artist_gallery WHERE artist_picid='$id'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { Here the part I just can't figure.... what I want is to fetch the x number of picture in the DB into a html table : Code: [Select] echo " <table border=\"1\" cellpadding=\"1\" cellspacing=\"0\"> <tr> <td><img src=\"".$info['picture']."\" border=\"0\" /></td> <td><img src=\"".$info['picture']."\" border=\"0\" /></td> <td><img src=\"".$info['picture']."\" border=\"0\" /></td> </tr> </table> "; } ?> The pictures are just repeating 3 times at each row... Any help will be greatly appreciated!!! Thanks! Hi there I followed this post http://www.phpfreaks.com/forums/index.php?topic=95426.0 to get a multi-column layout of search results. All's well but I seem to have an extra blank row at the bottom of the table. This is my code for the table Code: [Select] echo '<table width="800px" class="center" border="1">'; echo '<td>'; if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 3; while ($list = mysql_fetch_array($result)) { // make the variables easy to deal with extract($list); // open row if counter is zero if($i == 0) echo "<tr>"; echo '<td><a href="word.php?w=' . $list['word'] . '">' . $list['word'] . '</a></td>'; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } echo '</tr>'; echo '</table>'; Any ideas on how not to have it there? Thanks in advance. Hi
I have a table i populate from database (upon a parameter the user insert and with PHP $_GET i take this value and populate the table accordint to if). After I allow the user to add or edit data in rows by using jquery. The last part I do is to want to save the changes back to database using PHP. The jquery i use suppose to serve different tables. So its written in a way that get the table structure and add rows upon it. In this example I put it in the index page Everything works fine,but I cant build the array from the added rows. My variables in the php part got null values (although in debug mode I see that $_POST... store data in the array What do I miss here? Thanks here is my php+ html part of index,php <?php require_once("../xxx/Includes/GlDbOra.php"); if(isset($_POST['submit_btn'])) { $catalog_id=$_GET['catalog_id']; $tableRow = $_POST['tableRow']; foreach ($tableRow as $row) { $item_id=$row['ITEM_ID']; $item_name=$row['ITEM_NAME']; $userid=$_SESSION['userid']; $program='PHP'; $stid=DBOracle::getInstance()->insert_items($catalog_id, $item_id, $item_name, $userid, $program); } } if (!empty($_GET['catalog_id'])) { $catalog_id=trim($_GET['catalog_id']); $catalog_id_desc=$_GET['catalog_id_desc']; $stid=DBOracle::getInstance()->get_items($catalog_id); } ?> <html> <head> <meta charset="UTF-8"> <title>Items</title> <script type="text/javascript" src="../../Bundles/php-ajax/jquery-3.5.1.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script> <script type="text/javascript" src="../../Bundles/bootstrap-4.5.0-dist/js/bootstrap.min.js"></script> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link href="../../Bundles/bootstrap-4.5.0-dist/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <link href="../xxx/css/global_style.css" type="text/css" rel="stylesheet" madia="all"/> </head> <body> <div id="page-wrap"> <section id="main-content"> <div id="guts"> <span style="clear: both; float: left; margin-left: 5%;"> <form id="param_form" name="populate_table" method="GET" action="index.php"> <label for="catalog_id">Catalog Id</label> <input type="text" name="catalog_id" class="catalog_id" id="left_radius_textbox" value=" <?php echo htmlspecialchars($catalog_id, ENT_QUOTES); ?>" placeholder="<?php echo catalog_id; ?>"/> <input type="text" name="catalog_id_desc" class="catalog_id_desc" id="right_radius_textbox" value=" <?php echo htmlspecialchars($catalog_id_desc, ENT_QUOTES); ?>" readonly /> <button class="load_form"><span class="glyphicon glyphicon-refresh"></span> Get Data</button> </form> </span> <br> <div class="container"> <div class="row"> <div class="panel panel-primary filterable"> <div class="panel-heading"> <h3 class="panel-title">Items</h3> <div class="pull-right"> <button class="btn btn-default btn-xs btn-filter"><span class="glyphicon glyphicon-filter"></span> Filter</button> </div> </div> <form id="form" name="form1" method="POST" action=""> <table class="table table-fixed" id="tab_logic"> <thead> <tr class="filters" id ="table_header_2_btn"> <th class="col-xs-2"><input type="text" name="tableRow[0]['ITEM_ID']" value="" placeholder="Item Id" disabled></th> <th class="col-xs-6"><input type="text" name="tableRow[0]['ITEM_NAME']" value="" placeholder="Description" disabled></th> <th class="col-xs-4"></th> </tr> </thead> <tbody> <?php $catalog_id=$_GET['catalog_id']; $count=0; while ($row= oci_fetch_array($stid, OCI_ASSOC)): echo "<tr>"; echo "<td class=".'"col-xs-2"><input name="tableRow['.$count.']['."'ITEM_ID']".'"'.' value="'.htmlspecialchars($row['ITEM_ID'], ENT_QUOTES).'" style='."'border:none;".'></td>"'; echo "<td class=".'"col-xs-6"><input name="tableRow['.$count.']['."'ITEM_NAME']".'">'.htmlspecialchars($row['ITEM_NAME'], ENT_QUOTES)."</td>"; $count++; ?> <td class="col-xs-4"> <a class="add" title="Add" data-toggle="tooltip"><i class="material-icons"></i></a> <a class="edit" title="Edit" data-toggle="tooltip"><i class="material-icons"></i></a> <a class="delete" title="Delete" data-toggle="tooltip"><i class="material-icons"></i></a> </td> <?php echo "</tr>\n"; endwhile; oci_free_statement($stid); oci_close($con); ?> </tbody> <tr> <button class="regular_button" id="add-new"><span class="glyphicon glyphicon-plus"></span> Add Rows</button> <td><input type="submit" name="submit_btn" value="Submit"></td> </tr> </table> </form> </div> </div> </div> </div> </section> </div> <script> </script> </body> </html> and here is the jquery part in the index.php (that in between the <script></script>) $(document.body).on('click', '#add-new', function() { $('[data-toggle="tooltip"]').tooltip(); var actions = $("#tab_logic td:last-child").html(); $(this).attr("disabled", "disabled"); var index = $("#tab_logic tbody tr:last-child").index(); var newRow = $("<tr>"); var cols = ""; var element_string=''; var table_structure = $('#table_header_2_btn')[0].innerHTML; table_structure=$.trim(table_structure); var arrStr = table_structure.split(/\n/g); for(var i=0; i<arrStr.length-1; i++) { arrStr[i] =$.trim(arrStr[i]); element_string=arrStr[i]; if (element_string.indexOf('<th')!=-1) { var n=element_string.indexOf('<th'); element_string='<td'+ element_string.substr(n+3); var n=element_string.indexOf('[0]'); element_string= element_string.substr(0,n)+'['+index+']'+element_string.substr(n+3); } if (element_string.indexOf('placeholder=')!=-1) { var n=element_string.indexOf('placeholder='); element_string=element_string.substr(0,n-1); element_string=element_string + '</td>'; } cols+=element_string; } cols+='<td class="col-xs-4">' + actions + '</td>' cols +='</tr>'; newRow.append(cols); $('#tab_logic').append(newRow); $("#tab_logic tbody tr").eq(index + 1).find(".add, .edit").toggle(); $('[data-toggle="tooltip"]').tooltip(); }); $(document).on("click", ".add", function() { var empty = false; var input = $(this).parents("tr").find('input[type="text"]'); input.each(function() { if(!$(this).val()) { $(this).addClass("error"); empty = true; } else { $(this).removeClass("error"); } }); $(this).parents("tr").find(".error").first().focus(); if(!empty) { input.each(function() { // $(this).parent("td").html($(this).val()); }); $(this).parents("tr").find(".add, .edit").toggle(); $("#add-new").removeAttr("disabled"); } }); $(document).on("click", ".edit", function() { $(this).parents("tr").find("td:not(:last-child)").each(function() { $(this).html('<input type="text" value="' + $(this).text() + '">'); }); $(this).parents("tr").find(".add, .edit").toggle(); $("#add-new").attr("disabled", "disabled"); }); $(document).on("click", ".delete", function() { $(this).parents("tr").remove(); $("#add-new").removeAttr("disabled"); });
Hello again, I'm trying to scrape a table from another website using preg_match, especifically, using this code: Code: [Select] <?php $data = file_get_contents('http://tvcountdown.com/index.php'); $regex = '/[color=red]<table class="episode_list_table">[/color] (.+?) [color=red]</table>[/color]/'; preg_match($regex,$data,$match); var_dump($match); echo $match[0]; ?> Heres the thing. It doesnt work I think it's because the first and second anchors are html tags, 'cause if I parse some other stuff without any tag, there's no problemo. Any hints, mates? Thanks hi, I'm working with a script I've written (with a *lot* of help!!) I'm trying to get the results of a db search to be displayed in a html table, with a row for each result. I'm almost there, I've got 1 glitch and 1 cosmetic issue I can't resolve with the below script, any help would be greatly appreciated!! 1. the table displays the entire contents of the db before it is filtered through the search, I think this has something to do with the $num=mysql_numrows($result); expression, but I'm not sure how to fix it 2. I'd like the last column of the table to be about twice as wide as the others, as it contains a lot of free text, would I have to set the length of each column in order to do this or is there a shorthand way? the current script is: <form method="post" name="Search" action="test2.php"> <input type="text" name="name" autocomplete="OFF" /> <input value="Search" type="submit" name="Search" /> <input value="yes" type="hidden" name="submitted" /> </form> <?php if($_POST['submitted'] == 'yes') $username="*****"; $password="*****"; $database="*****"; $server="localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle) or die( "Unable to select database"); $query="SELECT * FROM ***** WHERE surname LIKE '" . mysql_real_escape_string($_POST['name']) . "%'"; $result=mysql_query($query) or die ('<br>Query string: ' . $SQL . '<br>Produced error: ' . mysql_error() . '<br>'); if (mysql_num_rows($result) == 0) { echo "No results found"; exit; } $num=mysql_numrows($result); $fields_num = mysql_num_fields($result); echo "<h1>Table: {$table}</h1>"; echo "<table border='1'><tr>"; for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; while($row = mysql_fetch_row($result)){ echo "<tr>"; foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); mysql_close($db_handle); ?> Have never done this before, but I'm sure many of you have. What I am trying to do is take the information that the user fills out in this form and when they hit submit, it will be displayed into a html table on the next page. I don't need someone to do the entire table for me, just looking for some help to get started and a general idea of what to do. Here is my code for my form that I have created... Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Lab 4</title> </head> <body> <?php ?> <form method="POST" action="lab4form.php"> <label for="first_name">First Name:</label> <input type="text" id="first_name" name="first_name" /><br /> <label for="last_name">Last Name:</label> <input type="text" id="last_name" name="last_name" /><br /> <label for="coverage_amount">Coverage Amount:</label> <input type="text" id="coverage_amount" name="coverage_amount" /><br /> <label for="gender">Gender:</label> <br> <input id="male" type="radio" value="radiobutton" name="male" /> <label for="male">Male</label> <input id="female" type="radio" value="radiobutton" name="female" /> <label for="female">Female</label> <br /> <br> <label for="Age">Age:</label> <input type="text" id="age" name="age" /><br /> <br> <label for="health">Health Conditions</label> <br /> <input type="checkbox" name="health" value="heart" /> <label for="health">Heart Disease</label><br /> <input type="checkbox" name="health" value="diabetes" /> <label for="health">Diabetes</label><br /> <input type="checkbox" name="health" value="blood" /> <label for="health">High Blood Pressure</label><br /> <input type="checkbox" name="health" value="Smoker" /> <label for="health">Smoker</label><br /> <input type="checkbox" name="health" value="lung" /> <label for="health">Lung disease</label><br /> <FORM METHOD=POST ACTION="lab4form.php"> <P>Employment Status<BR> <SELECT NAME="employment"> <OPTION VALUE="lab4form.php">Unemployed <OPTION VALUE="lab4form.php">Full-Time <OPTION VALUE="lab4form.php">Part-Time <OPTION VALUE="lab4form.php">Student </SELECT><br /> <br> <label for="comments">Comments</label> <input type="text" id="comments" name="comments"/><br /> <br> <input type="submit" value="Add User" name="btn_add" /> </form> </body> </html> Hello I have 2 database tables: 1) products which contain 3 columns: id, description and unit 2) units which contains 2 columns: id and description I need to pupulate html table with data from 2 database tables.this is the structu id, description, unit, unit_description (the first 3 columns come from table 1 and the fourth column from table 2 I know hot to pupulate the table according to the 3 columns: (the remarks are for the 4th column that i dont know how to call). I want this column to get the description of the unit in the row from the second table in the database - using the get_unit_desc in the GlDbOra.php file (Not by making a join in the select) How can I do that? I'll be happy for any help index.php <?php require_once("../xxx/Includes/GlDbOra.php"); $cursor=''; $cursor=DBOracle::getInstance()->get_products(); ?> <html> <head> <meta charset="UTF-8"> <title>Products</title> <script type="text/javascript" src="../../Bundles/php-ajax/jquery-3.5.1.js"></script> <script src="../Bundles/bootstrap-4.5.0-dist/js/bootstrap.min.js"></script> <link href="../Bundles/bootstrap-4.5.0-dist/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <link href="../xxx/css/global_style.css" type="text/css" rel="stylesheet" madia="all"/> </head> <body> <div class="container"> <div class="row"> <div class="panel panel-primary filterable"> <div class="panel-heading"> <h3 class="panel-title">Products</h3> <div class="pull-right"> <button class="btn btn-default btn-xs btn-filter"><span class="glyphicon glyphicon-filter"></span> Filter</button> </div> </div> <form id="data_form" name="datatable_form" method="POST"> <div class="table-repsonsive"> <table class="table table-bordered" id="tab_logic"> <thead> <tr class="filters" id="table_header_2_btn"> <th width="12%"><input type="text" class="form-control" name="Id[]" value="" placeholder="Id" disabled /></th> <th width="30%"><input type="text" class="form-control" name="DESCRIPTION[]" value="" placeholder="Description" disabled /></th> <th width="12%"><input type="text" class="form-control" name="UNIT[]" value="" placeholder="Unit" disabled /></th> <!-- <th width="30%"><input type="text" class="form-control" name="UNIT_DESCRIPTION[]" value="" placeholder="Description" disabled /></th> --> <th width="12%"></th> </tr> </thead> <tbody> <?php foreach ($cursor as $cursorCurrentRow) { echo '<tr class="form-group">'; echo "<td width=".'"12%"><input type="text" name="ID[]" value="'.htmlspecialchars($cursorCurrentRow['ID'], ENT_QUOTES).'" disabled style="border:none;"></td>'; echo "<td width=".'"30%"><input type="text" name="DESCRIPTION[]" value="'.htmlspecialchars($cursorCurrentRow['DESCRIPTION'], ENT_QUOTES).'" disabled style="border:none;"></td>'; echo "<td width=".'"12%"><input type="text" name="UNIT[]" value="'.htmlspecialchars($cursorCurrentRow['UNIT'], ENT_QUOTES).'" disabled style="border:none;"></td>'; // echo "<td width=".'"30%"><input type="text" name="UNIT_DESCRIPTION[]" value="'.htmlspecialchars($cursorCurrentRow['DESCRIPTION'], ENT_QUOTES).'" disabled style="border:none;"></td>'; echo "<td width=".'"12%">' . '<a class='.'"add" title='.'"Add" data-toggle='.'"tooltip"><i class='.'"material-icons"></i></a>' . '<a class='.'"edit" title='.'"Edit" data-toggle='.'"tooltip"><i class='.'"material-icons"></i></a>' . '<a class='.'"delete" title='.'"Delete" data-toggle='.'"tooltip"><i class='.'"material-icons"></i></a>' . '</td>'; echo "</tr>\n"; } ?> </tbody> </table> </div> </form> </div> <button class="regular_button" id="add-new"><span class="glyphicon glyphicon-plus"></span> Add Rows</button> <button class="regular_button" id="save_rows"><span class="glyphicon glyphicon-floppy-save"></span> Save</button> </div> </div> </body> </html> GlDbOra.php <?php class DBOracle { private static $instance = null; public static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self; } return self::$instance; } 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 () { $databaseConfig = include 'config.php'; $OracleUser=$databaseConfig['Oracle_User']; $OraclePwd=$databaseConfig['Oracle_Pwd']; $OracleDB=$databaseConfig['Oracle_DB']; $this -> OracleUser = $OracleUser; $this -> OraclePwd = $OraclePwd; $this -> OracleDB = $OracleDB; $this->con = oci_connect($this->OracleUser, $this->OraclePwd, $this->OracleDB); if (!$this->con) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); exit; } } public function get_products() { $cursor=''; $query = "begin get_products(:cursor); end;"; $stid = oci_parse($this->con, $query); $p_cursor = oci_new_cursor($this->con); oci_bind_by_name($stid, ':cursor', $p_cursor, -1, OCI_B_CURSOR); oci_execute($stid); oci_execute($p_cursor, OCI_DEFAULT); oci_fetch_all($p_cursor, $cursor, null, null, OCI_FETCHSTATEMENT_BY_ROW); oci_free_statement($stid); oci_close($this->con); return $cursor; } public function get_unit_desc($unitid) { $unit_desc=''; $query = "begin :unit_desc_bv := get_unit_desc(:id_bv); end;"; $stid = oci_parse($this->con, $query); oci_bind_by_name($stid, ':id_bv', $unitid); oci_bind_by_name($stid, ':unit_desc_bv', $unit_desc,30); oci_execute($stid); oci_free_statement($stid); oci_close($this->con); return $unit_desc; } } ?>
I have a table that allows users to add rows, depending on how much data they need to insert. upon submit I'd like to populate another table for review. Now I can generate the data, but I'm having trouble putting the array into a table. Here is the output from the initial page: Code: [Select] Array ( [quantity] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [description] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [unit_cost] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [shipping] => 4 [tax] => 5 [review_po] => Review ) I need it to look like this: Quantity | Description | Unit Cost 1 | 1 | 1 2 | 2 | 2 3 | 3 | 3 Tax | 4 Ship | 5 I think it's a foreach statement, but I'm not having any luck.. If someone could point me in the right direction??? Hi all, I'm new to php/myslq and I'm going crazy trying to figure this one out I'm building a personal calendar and I want to display the data into a HTML table. Code: [Select] //query the database $query = "SELECT * FROM tbl_events WHERE event_day=$day AND event_month=$month AND event_year=$year"; $query = mysql_query($query); //build the table echo '<table>'; for ($y = 0; $y < 6; $y++){ echo '<tr><td>'; //insert the data here echo '</td></tr>'; } echo '</table>'; When I store the events into the database, I assign a slot for each one depending on the hour. I don't want to use more than 6 events daily, hence the for loop. The problem I have is how to I insert the data into the designed <td>? In a particular day I could have only 2 events: event 1 - slot 2, event 2 - slot 6. I want to be able to enter each event into its own cell I hope I'm making myself clear enough. Sorry for any English mistakes if any. Thank you Here is my code. $display_block .= " <P>Showing posts for the <strong>$topic_title</strong> topic:</p> <table width=100% cellpadding=3 cellspacing=1 border=1> <tr> <th>AUTHOR</th> <th>POST</th> </tr>"; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); //add to display $display_block .= " <tr> <td width=35% valign=top>$post_owner<br>[$post_create_time]</td> <td width=65% valign=top>$post_text<br><br> <a href=\"replytopost.php?post_id=$post_id\"><strong>REPLY TO POST</strong></a></td> </tr>"; } //close up the table $display_block .= "</table>"; } ?> <html> <head> <title>Posts in Topic</title> </head> <body> <h1>Posts in Topic</h1> <?php print $dislplay_block; ?> </body> </html> |