PHP - Extra Row In Html Table
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. 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. 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 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? 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? 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! 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? <?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! 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? 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); ?> 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 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; } } ?>
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> I know how much you guys hate people asking for help without any starting code but I'm not even sure how to start this.. I want a script to read this page and count all the admins and referees. If anyone is willing to help, here's a sample of the html code: Code: [Select] <div class="boxInner"><h3>Arena Referees</h3><table class="list"><thead><tr><th style="width:16px;"></th><th style="width:150px;">Name</th><th style="width:300px;">Position</th><th style="width="150px;">Gamertag</th></tr></thead><tbody><tr><td><a href="http://gamebattles.com/profile/GottaHaveFaith78"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td><td class="alt1">Faith</td><td><b>Head Referee</B></td><td class="alt1">GB CombatBarbie</td></tr><tr><td class="alt2"><a href="http://gamebattles.com/profile/Jack.-"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td><td>Jack</td><td class="alt2"><b>Asst. Head Referee</b></td><td>Get Jacked x</td></tr><tr><td><a href="http://gamebattles.com/profile/amghawk"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td><td class="alt1">Mike</td><td><b>Asst. Head Referee (IS)</b></td><td class="alt1">GB amghawk</td></tr><tr><td class="alt2"><a href="http://gamebattles.com/profile/cory94bailly"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td><td>Cory</td><td class="alt2">Referee</td><td>Cory xz</td></tr><tr><td><a href="http://gamebattles.com/profile/crago"><img src="http://media.gamebattles.com/icons/16/profile.png" class="icon16" /></a></td> I'm just wondering how I could even count them. Any help will be appreciated, thanks. 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??? I want to print in an html table the Seasons,the Months,and the days of each month. the following code prints the seasons and the days i need another foreach in between that prints the months also Any ideas??? Please help... $seasons=array ( "Fall"=> array ("September"=>"30","October"=>"31","November"=>"30"), "Winter"=> array ("December"=>"31","January"=>"31","February"=>"28"), "Spring"=> array ("March"=>"31","April"=>"30","May"=>"31"), "Summer"=> array ("June"=>"30","July"=>"31","August"=>"31") ); $tab = "<table border=\"1\">"; foreach($seasons as $season => $months) { $tab .= "<tr><td colspan=\"4\">$season</td></tr>" ; $tab .= "<tr>" ; foreach($seasons[$season] as $days) { $tab .= "<td>$days</td>" ; } $tab .= "</tr>" ; } $tab .= "</table>" ; echo $tab ; 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 Hi guys I am new here I have had a search around and can't really find out how to do this. Its quite difficult for me to explain and I am really new to PHP / mySQL - just starting out really. I hope to learn from doing small projects like this and seeing how it gets done. So I have a mySQL DB with two different tables - one is called "notesnew" the other is called "users". I have modified a common tutorial on how to make a "to do list" for what I am doing here. Basically users can login and post messages on this list as them self. Each user's post appears as a list item, showing their username, the time they posted the message and the message content. The message content, time and owner of the message is stored in the "notesnew" table. The list of user's, their passwords and their "avatar/profile" image URL location is stored in the "users" table. Now I am having trouble getting each user's avatar image from being output next to each of their posts. The part that is confusing me is being able to match up the username's post with their content that is display - because I am posting the user's name along with their post, based on the logged in "session name" as their username. So basically, all the content being listed is being displayed from the "notesnew" table. I need to somehow figure out what each user's profile image is based on what is stored against their entry in the "users" table. Here is the code I have so far. It is not working properly - it displays all content etc, but displays the avatar / image of the last user that has registered. Can anyone help me out here with some code that works, or pointers to try follow? I know the $finduserprofile part is incorrect in the way it goes through all user's and finds their profileimg, and that the image displayed next to each post is therefore incorrect (as it displays the last member to have registered's avatar, but its just that I don't know how else to do what I am trying to do. Code: [Select] <?php //Connect to the database $connection = mysql_connect('localhost', 'zzzz' , 'zzzzzzz'); $selection = mysql_select_db('zzzzz', $connection); $username = $_COOKIE['ID_my_site']; //Was the form submitted? if($_POST['submit']){ //Map the content that was sent by the form a variable. Not necessary but it keeps things tidy. $content = $_POST['content']; //Insert the content into database $ins = mysql_query("INSERT INTO `notesnew` (content, owner, dp_time) VALUES ('$content', '$username', NOW())"); //Redirect the user back to the members or index page header("Location:index.php"); } /*Doesn't matter if the form has been posted or not, show the latest posts*/ //Find all the notes in the database and order them in a descending order (latest post first). $find = mysql_query("SELECT * FROM `notesnew` ORDER BY id DESC"); $finduserprofile = mysql_query("SELECT * FROM `users` ORDER BY id DESC"); //Setup the un-ordered list echo '<ul>'; while($row = mysql_fetch_array($finduserprofile)) { $imagelocation = $row['profileimg']; //Continue looping through all of them while($row = mysql_fetch_array($find)) { $owner = $row['owner']; //For each one, echo a list item giving a link to the delete page with it's id. echo '<li>' . '<img src ="' . $imagelocation . '">' . $row['owner'] . ' said at ' . $row['dp_time'] . ': ' . $row['content'] . ' <a id="' . $row['id'] . '" href="delete.php?id=' . $row['id'] . '"><img src="delete.png" alt="Delete?" /></a></li>'; } } //End the un-ordered list echo '</ul>'; ?> |