Jump to content

Search the Community

Showing results for tags 'table'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi there, I have a timetable plugin that shows booking entries. The times are generated dynamically by the plugin. Now I have the situation where I need to override the automatically created time that shows in a table row. Here's the HTML code generated by the plugin: <tr class="row_12"> <td class="tt_hours_column">00:00</td> Ist it possible to have a simple PHP script that does the following (please forgive my noobiness) ? if table row is "row_12" then insert "my own pre-defined time" Please don't hate on me, I know I have not the slightest idea about php. I'm just wondering how to solve my plugin problem and if PHP is the right way to do it. I highly appreciate any feedback from you guys
  2. Hello, I know this should be pretty simple to figure out, but everything I try is giving me absolutely no results. I have a mysql query selecting columns from my database and returning results. I have the results printing out right now, so I can see that this part is working. All I want to do is take the results and put them into a table to display on my page. Basically, take what's in the database table and copy it to a table I can put on the web. FYI I am using sourcerer so the "connect" code is taken care of for me in the "JFactory" bit of code. Here is the first part of my code, selecting the information from the database. {source} <?php $db = JFactory::getDbo(); $query = $db -> getQuery(true); $query -> SELECT($db -> quoteName(array('first_dept_name', 'last_name', 'dept', 'position', 'phone_num'))); $query -> FROM ($db -> quoteName('#__custom_contacts')); $query -> ORDER ('first_dept_name DESC'); $query -> WHERE ($db -> quoteName('contact_category')."=".$db -> quote('YTown Employees')); $db -> setQuery($query); $results = $db -> loadObjectList(); print_r($results); Here is where I am trying to print the results into a table. I got this code directly from a PHP book, but I am getting nothing at all returned back to me. I get table headers, but no data. <?php echo "<table><tr><th>Name</th><th>Department</th></tr>"; while ($row = mysqli_fetch_array ($result)){ echo "<tr>"; echo "<td>".$row['last_name']."</td>"; echo "<td>".$row['dept']."</td>"; echo "</tr>"; } echo "</table>"; ?> {/source}
  3. Here is my code so far (I say it's PDO but it pretty much isn't. What is the object here? The database connection? LOL!); $sql = " SELECT SUM(IF(`sent` != 'N' , 1 , 0 )) as 'Emails Sent', SUM(IF(`completed` NOT IN('N','paper') , 1 , 0 )) as 'Completed Electronically', SUM(IF(`completed` = 'paper' , 1 , 0 )) as 'Completed Manually', SUM(IF(`completed` != 'N' , 1 , 0 )) as 'Total Number Completed', SUM(IF(`remindercount` = '1' , 1 , 0 )) as 'Reminder Sent Once', SUM(IF(`remindercount` = '2' , 1 , 0 )) as 'Reminder Sent Twice', SUM(IF(`remindercount` = '3' , 1 , 0 )) as 'Reminder Sent Thrice' FROM `tokens_$survey_id` "; $statement = $dbh->prepare($sql); $statement->execute(); $result = $statement->fetch(PDO::FETCH_OBJ); foreach($result as $key => $value) { echo "<tr> <td>$key</td> <td>$value</td> </tr>"; } This is all well and good if the tokens_$survey_id table is actually there. Sometimes, for a genuine reason, there won't be a tokens table for that particular survey. How do I account for this? At the moment I get an error.. Warning: Invalid argument supplied for foreach() in /var/www/html/index.php on line 149 I tried this but I am not satisfied this is correct; if(!$result) { die(); } I don't want the code to die! If I take out the die() statement then this if is ignored for some reason I don't understand.
  4. Ok, so I have some code that takes the records in my database and outputs them in a table, but currently after the first record it starts spacing them incorrectly Here is the code <?php require_once('config.php'); require_once('menu.php'); echo '<h1>View All Alien Interactions</h1>'; echo '<table> <tr>'; foreach($fields AS $label){ echo "<th>{$label}</th>"; } echo '<th>Edit</th><th>Delete</th>'; echo '</tr>'; $fields_str = '`contact_id`, `'.implode(array_keys($fields), '`, `').'`'; $sql = "SELECT {$fields_str} FROM `alien_abduction`"; foreach($dbh->query($sql) as $row) { echo '<tr>'; foreach($fields AS $field=>$value){ echo '<td>'.(isset($row[$field]) && strlen($row[$field]) ? $row[$field] : '&nbsp'.'</td>'); } echo '</tr>'; echo '<td><a href="edit.php?contact_id='.$row['contact_id'].'">Edit</a></td>'; echo '<td><a href="delete.php?contact_id='.$row['contact_id'].'">Delete</a></td>'; echo '</tr>'; echo '</table>'; } ?> I just want it to start a new line after importing each record This is a picture of what its curently doing, look at the second row, it just keeps adding all additional entries on this line (I whited out personal info)
  5. I have an existing two table structure where sub-data is related to main data in a many-to-one relationship. There are several identically named columns in both tables. (The PHP database class will return an associative array that did not deal with identical keys in the row.) I'm LEFT JOINing the sub-data to the main-data tables. When using a stand-alone query browser (to experiment), the display shows all columns, even those column names that appear more than once in the row. Is there a general approach to making keys (column names) unique strictly using a MySQL SELECT statement? Perhaps using table aliases, how can I concat the alias to the columns that come from each table? What I am trying to avoid is giving an alias to each column in a list of column names, such as: SELECT C.name AS C_name C.numb AS C_numb D.name AS D_name D.numb AS D_numb etc. I am wanting more like the result one could guess would be from: C.* AS C_* D.* AS D_* Or better: * AS CONCAT(__TABLE__, '_', *) if __TABLE was a magic constant (like PHP's __LINE__, __FILE__, etc).
  6. hi i would like to know why this doesnt work .the problem is that it doesnt give me multiple tr-s like td-s.it only works for one tr and multiple td-s. help apreciated <html><head> </head> <body> <?php function myt($border,$column,$row,$words){ $table="<table border='".$border."'>"; if($column==1){ $table.='<tr>'; for($i=1;$i<=$row;$i++){ $table.="<td>".$words."</td>"; };//end of for $table.='</tr>'; }//end of if else{ for($i=1;$i<=$column;$i++){ $table.="<tr border='".$border."'>"; for($i=1;$i<=$row;$i++){ $table.='<td>'.$words.'</td>'; } $table.='</tr>'; };//end of column for };//end of else $table.="</table>"; return $table; };//end of function //echo myt (1,1,10,'word'); WORKS!!! echo myt(1,2,4,'lalalala'); ?> </body> </html>
  7. hi, i am a total newbie. with some idiosyncratic knowledge of actionscript.. so please apologies if this has been answered before or if it so bleeding obvious.. trying searching but i dont really know what to search for.. why does this following simple code add space above the php code? it appears that every <tr> you add, the equivalent space appears above the php code: <html> <body> <table bgcolor="#FF9900" width="100%" border="0"> <tr> <td> <?php echo '<table width="100%"> <tr bgcolor="#FFFFF"> <td> say something </td><br/> <td> and something else</td> </tr> <tr bgcolor="#FFFFF"> <td> say something </td><br/> <td> and something else</td> </tr> <tr bgcolor="#FFFFF"> <td> say something </td><br/> <td> and something else</td> </tr> </table>' ?> </td> </tr> </table> </body> </html>
  8. hi,,, i need question about populate table based on dropdown this my php file kecamatan.php <?php require 'config_db.php'; $self='kelurahan.php'; if (isset($_POST['action'])&&$_POST['action']=='edit'){ $namakelurahan = _post('namakelurahan'); if ($namakelurahan==''){ r2($self,'e','Nama kelurahan tidak boleh kosong'); } $id = _post('id'); $grp = ORM::for_table('kelurahan')->find_one($id); $grp->set('namakelurahan', $namakelurahan); $grp->save(); r2($self,'s','Perubahan data berhasil di lakukan'); } elseif (isset($_POST['action'])&&$_POST['action']=='delete'){ $trid = _post('trid'); $tr = ORM::for_table('kelurahan')->find_one($trid); if (!$tr){ r2($self,'e','Nama kelurahan tidak di temukan'); } $tr->delete(); r2($self,'s','Data berhasil di hapus'); } elseif (isset($_POST['action'])&&$_POST['action']=='add'){ $namakelurahan = _post('kelurahan'); if ($namakelurahan==''){ r2($self,'e','Nama kelurahan wajib diisi'); } $grp = ORM::for_table('kelurahan')->create(); $grp->namakelurahan=$namakelurahan; $grp->save(); r2($self,'s','kelurahan berhasil disimpan'); } else {?> <?php $query ="SELECT * from kecamatan"; $stmt = $dbh->prepare("$query"); $stmt->execute(); $reskecamatan = $stmt->fetchAll(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><?php echo 'Sistem Informasi Surveilans' // lc('WebsiteTitle'); ?></title> <link rel="shortcut icon" type="image/x-icon" href="../assets/img/favicon.ico"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link type='text/css' href='views/bmsapp/css/cstyle.css' rel='stylesheet' /> <link href="../assets/css/bootstrap.min.css" rel="stylesheet"> <link href="../assets/css/bootstrap-responsive.min.css" rel="stylesheet"> <link href="../assets/css/clientstyle.css" rel="stylesheet"> <link href="../assets/css/common.css" rel="stylesheet" type="text/css" /> </head> <body style='background-color: #FBFBFB;'> <div id='main-container'> <div class='header'> <div class="header-box wrapper"> <div class="hd-logo"><a href="#"><img src="../assets/uploads/logo.png" alt="Logo"/></a></div> </div> </div> <div class="navbar"> <?php include 'menu.php';?> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> <h3>Data kelurahan</h6> <table> <tr> <td> Kecamatan : <select onchange=""> <option value="-1">Semua Kecamatan</option> <?php foreach($reskecamatan as $allkecamatan) { $id = $allkecamatan['id']; $namakecamatan = $allkecamatan['namakecamatan']; ?> <option value="<?php echo $allkecamatan['id']?> "> <?php echo $allkecamatan['namakecamatan']; ?> </option> <?php } ?> </select> </td> </tr> </table> <table class="table table-bordered table-striped table-hover"> <tr> <th scope="col">No</th> <th scope="col" style="display:none;">Id kelurahan</th> <th scope="col">Nama kelurahan</th> <th scope="col">Nama Kecamatan</th> <th scope="col">Olah Data <img id="ajxspin" src='../assets/img/blue_spinner.gif'/></th> </tr> <?php $query ="SELECT kelurahan.id, kelurahan.idkecamatan, kecamatan.namakecamatan, kelurahan.namakelurahan FROM kecamatan INNER JOIN kelurahan ON kelurahan.idkecamatan = kecamatan.id"; $stmt = $dbh->prepare("$query"); $stmt->execute(); $result = $stmt->fetchAll(); $i='0'; foreach($result as $accgroup) { $i++; $id = $accgroup['id']; $namakelurahan = $accgroup['namakelurahan']; $namakecamatan = $accgroup['namakecamatan']; echo "<tr> <td>$i</td> <td style=\"display:none;\">$id</td> <td>$namakelurahan</td> <td>$namakecamatan</td> <td><a href=\"kelurahan.edit.php?_cmd=$id\" data-toggle=\"modal\"><i class=\"icon-pencil\"></i></a> <a href=\"kelurahan.delete.php?_cmd=$id\" data-toggle=\"modal\"><i class=\"icon-remove\"></i></a></td> </tr>";} ?> <tr> <!--td colspan="3"><a class="btn btn-inverse" href="my-tickets.php"><?php echo 'view' ?> <?php echo 'all_support_tickets' ?></a> <a class="btn btn-primary" href="create-ticket.php"><?php echo 'new_ticket' ?></a></td--> <td colspan="4"> <a class="btn btn-inverse" href="kelurahan.add.php" data-toggle="modal" ><i class="icon-plus icon-white"></i>Tambah Data</a> <a class="btn btn-primary" href="kelurahan.lap.php"><i class="icon-list icon-white"></i>Laporan</a> </td> </tr> </table> </div> </div> </div> </div> </div> <div class="footer"><?php echo $footerTxt; ?><br /><br /></div> </body> </html> <?php } ?> and this output my code in browser: and my question, how to populate the table based on selected dropdown value? sorry my english is bad thanks b4
  9. Hello all! I'm makeing car booking module and have one problem. Explaining... There is tree joined tables "books", "car" and "cat". When i joining this three table it retrieves ids from table "car", but i want ids from "books" what to do? Can you help? Thanks <?php if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } $query = " SELECT * FROM books LEFT JOIN car ON books.car_id = car.id LEFT JOIN cat ON books.cat_id = cat.id WHERE books.owner = '$owner'"; $result = mysqli_query($db,$query) or die("Error: ".mysqli_error($db)); $myrow = mysqli_fetch_array($result, MYSQLI_BOTH); if(mysqli_num_rows($result) > 0){ if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } do { printf ('<tr> <td>'.$myrow["id"].'</td> <td>'.$myrow["model"].'</td> <td>'.$myrow["cat_name"].'</td> <td>'.$myrow["name"].'</td> <td>'.$myrow["surname"].'</td> <td>'.$myrow["country"].'</td> <td>'.$myrow["phone"].'</td> <td>'.$myrow["notes"].'</td> <td>'.$myrow["start_date"].'</td> <td>'.$myrow["end_date"].'</td> <td>'.$myrow["owner"].'</td> <td>'.$myrow["site"].'</td> <td><a href="delete.php?id='.$myrow["id"].'">Delete</a></td> </tr>'); } while ($myrow = mysqli_fetch_array($result)); } else{ echo '<p align="center" style="margin-top:100px;">There are no records...</p>'; } ?>
  10. Hi guys. I'm strunggling with one mysql query. Please help. The situation is following: I have 2 tables: +========= MENUS ===========+ | ID | menu_name | menu_link | | 21 | home | home.php | | 22 | products | products.php | | 23 | about | about.php | +============================+ +============== SUBMENUS ==============+ | ID | menus_id | submenu_name | submenu_link | | 1 | 22 | product 1 | product-1.php | | 2 | 22 | product 2 | product-2.php | | 3 | 23 | contacts | contactas.php | +=======================================+ my URL looks like www.domain.com/product-1.php?id=1 based on ID value from URL product-1.php?id=1 I need to display the Product 1 and Product 2 I tried something like this: "SELECT menus.id, submenus.* FROM menus, submenus WHERE menus.id=submenus.menus_id" but it gives me of course back everything from submenus. How can I reduce result to show me only product 1 and product 2 based on ID from URL ???? Thanks for any help.
  11. Hi all, I was wondering if you can help me with an issue I am having with my website. I am very new to php/html/css and mysql so I know very little. I have an order form on my website which when filled in send data to my database. I then have an admin page on my site which shows the data in the database. However, I need the data to be stored in a table with a row containing the column name and then each row showing the actual data underneath. Would like it in a grid sort of format. My current code is: <!doctype html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <link href="css/style.css" rel="stylesheet" type="text/css" /> <link href="css/reset.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container2"> <div id="adminpanel"> Admin Page <div id="showorders"><u>Orders</u></div> <?php include('connection.php'); $result = mysql_query("SELECT * FROM orderform"); while($row = mysql_fetch_array($result)) { echo "<span style='color: #333; width: 200px; height: 200px; padding: 1px; border: 1px solid #ff9900;'>" . $row['product'] . " " . $row['productcomments'] . " " . $row['name'] . " " . $row['address'] . " " . $row['age'] . " " . $row['delivery'] . "</span>" ; echo "<br>"; } ?> <div id="showreviews"><u>Reviews</u></div> <?php $result = mysql_query("SELECT * FROM reviewform"); while($row = mysql_fetch_array($result)) { echo "<span style='color: #333; width: 200px; height: 200px; padding: 5px; border: 1px solid #ff9900;'>" . $row['name'] . " " . $row['product'] . " " . $row['comment'] . "</span>" ; echo "<br>"; echo $row['name'] . " " . $row['product'] . " " . $row['comment'] ; echo "<br>"; } ?> </div> </div> </body> This code puts a border around each row but doesnt seperate each column and doesnt show a header. Ultimately, I am going to want to sort each order by different criteria e.g alphabetical, date ordered, product type. All help is really appreciated as I am really pushed for time and a complete beginner. Thanks Jonathan
  12. I am a PHP beginner. Every x days (every 7 days for example), I would like all the values in a certain column in my MySQL database to reset back to '1'. How do I do this? Please note: My web host does NOT have the MySQL event scheduler enabled so that is not an option. Also, my web hosting plan does not allow me to do cronjobs so that is not option either. Any other ideas? Thanks!
  13. Hi, I want to pivot a table and at this moment i use: SELECT e.guid AS id, e.guid AS guid, TYPE , subtype, md.owner_guid AS owner_guid, site_guid, container_guid, md.access_id AS access_id, username, name, e.time_created, time_updated, name, e.enabled, banned, e.last_action, last_login, MAX( IF( msn.string = 'custom_profile_type', msv.string, NULL ) ) AS custom_profile_type, MAX( IF( msn.string = 'field1', msv.string, NULL ) ) AS field1, MAX( IF( msn.string = 'field1', msv.string, NULL ) ) AS field1 FROM exp_metadata md JOIN exp_metastrings msn ON md.name_id = msn.id JOIN exp_metastrings msv ON md.value_id = msv.id JOIN exp_users_entity u ON u.guid = md.entity_guid JOIN exp_entities e ON e.guid = md.entity_guid GROUP BY guid You can see that I need the field 'field1' as a column with the value attached to it. The problem is that there are multiple fields called 'field1' basicly the options of a multiselect that my users can choose. Obviously using MAX I get the maximum value, ex. when they selected answer1, answer2 and answer3, this query will only fetch answer3. I want to know if there is a way that instead of just 'answer3' I can have the value to be: answer1,answer2,answer3 I'm sorry if it is not really clear. Thanks in advance.
  14. Hi, I'm currently trying to get my database for my website to work but at the moment I'm having a lot of issues with the new version? Basically I'm trying to create a simple registration table setup which includes: - user_id - firstname - lastname - username - email - password And the problem is that when I put them all in, set the Index's and the data types, it comes up with a message saying: "This is not a number"? I have no idea why it keeps coming up with this, any ideas? Here's what it looks like at the moment http://i.imgur.com/faOXjrs.png Thanks.
  15. I am wanting to echo a table if a field = x and if not echo another table. Can this be done easily? I have tried but not having much luck. Any help would be appreciated by this "on the fly" learner. Something like... IF AdviserCode=X then <table width="610" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="85">RCTI</td> <td width="85">Detail 1</td> <td width="85">Detail 2</td> <td width="85">Detail 3</td> <td width="85">Detail 4</td> <td width="85">Detail 5</td> </tr> <?php include("../edb.php"); $result=mysql_query("SELECT * FROM `afddocs_adviser_comm` WHERE AdviserCode =".$_SESSION['uid']." order by DateUploaded DESC"); while($test = mysql_fetch_array($result)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td><a class='".$test['RCTIcssclass']."'href =".$test['RCTIURL'].">".$test['RCTIImageType']."</a>"; echo"<td><a class='".$test['Detail1cssclass']."'href =".$test['Detail1URL'].">".$test['Detail1ImageType']."</a>"; echo"<td><a class='".$test['Detail2cssclass']."'href =".$test['Detail2URL'].">".$test['Detail2ImageType']."</a>"; echo"<td><a class='".$test['Detail3cssclass']."'href =".$test['Detail3URL'].">".$test['Detail3ImageType']."</a>"; echo"<td><a class='".$test['Detail4cssclass']."'href =".$test['Detail4URL'].">".$test['Detail4ImageType']."</a>"; echo"<td><a class='".$test['Detail5cssclass']."'href =".$test['Detail5URL'].">".$test['Detail5ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> OR (same table as above minus a couple of colums)
  16. I bought the following script http://www.sevenscript.net/ajax-powered-mysql-table-editor/. It is a ajax table editor with in-line editing It comes with the following files. ajaxtable.js /*Sevenscript <http://sevenscript.net> - Copyright (c) 2010 <info@sevenscript.net>*/ //Declare Some Global Variables var cancelString; var editTblRow; var editTblCell; var editSQLRowID; var editKey; var editCancel; function showDelete(id) { $("#del_" + id).toggle(); } function loadTable(){ $("#ajaxTable").load("table.php"); } function insertRow(){ $("#ajaxTable").load("dbFunc.php?action=new"); } function selectTable(optvalue){ editTblRow = null; editTblCell = null; $("#active_table").val(optvalue); $("#ajaxTable").load("table.php?table=" + optvalue); } function loadingTimer(){ $("#ajax_loading_div") .bind("ajaxSend", function(){ $(this).show(); }) .bind("ajaxComplete", function(){ $(this).hide(); }); } function delRow(thisRow,rowID){ var delConfirm = confirm("Delete this row?"); if (delConfirm){ $.get("dbFunc.php", { action: 'delete', rowid: rowID }, function(data){ $(thisRow).parent().fadeOut(500, function() {$(thisRow).remove(); }); }); } } function cancelInsert(rowID){ $.get("dbFunc.php", { action: 'delete', rowid: rowID }, function(data){ loadTable(); }); } function toggleDelRow(rowid){ $("#"+rowid).toggle(); } function searchTable(searchTerm){ loadingTimer(); $("#ajaxTable").load("table.php?search=" + encodeURI(searchTerm) + "&table=" + $('#active_table').val()); } function gotoStart(start){ loadingTimer(); var search_text = ''; if($("#searchText").val()!='Search'){search_text=$("#searchText").val()} $("#ajaxTable").load("table.php?start=" + start + "&search=" + search_text + "&table=" + $('#active_table').val()); } function sortTable(order_by,direction){ loadingTimer(); var search_text = ''; if($("#searchText").val()!='Search'){search_text=$("#searchText").val()} $("#ajaxTable").load("table.php?start=0&search=" + search_text + "&order_by=" + order_by + "&direction=" + direction + "&table=" + $('#active_table').val()); $("#" + order_by).attr("src","img' + '../img/ajax/arrow_down.gif"); } this.label2value = function(){ var inactive = "inactive"; var active = "active"; var focused = "focused"; $("label").each(function(){ obj = document.getElementById($(this).attr("for")); if($(this).attr("for")=="searchText"){ if(($(obj).attr("type") == "text") || (obj.tagName.toLowerCase() == "textarea")){ $(obj).addClass(inactive); var text = $(this).text(); $(this).css("display","none"); $(obj).val(text); $(obj).focus(function(){ $(this).addClass(focused); $(this).removeClass(inactive); $(this).removeClass(active); if($(this).val() == text) $(this).val(""); }); $(obj).blur(function(){ $(this).removeClass(focused); if($(this).val() == "") { $(this).val(text); $(this).addClass(inactive); } else { $(this).addClass(active); }; }); }; }; }); }; var t = document.getElementsByTagName("tr"); for(var i=0;i<t.length;i++) { var ocn = t[i].className; t[i].onmouseover = function() { t[i].className = "hovered" }; t[i].onmouseout = function() { t[i].className = ocn }; } function editCell(rowid,cellid,sqlrowid,key,id,type,fieldtype,updatestring) { if(type=='cancel'){ $($('#ajaxtb')[0].rows[editTblRow].cells[editTblCell]).hide().html(cancelString).fadeIn('slow'); $($('#ajaxtb')[0].rows[editTblRow].cells[editTblCell]).removeClass('tdHover'); showDelete(editTblRow-1); editCancel=true; } else if(type=='save'){ $.ajax({ url: 'database.php', type: 'GET', data: "text=" + $('#edit_box').val() + "&sqlrowid=" + editSQLRowID + "&field=" + editKey + "&table=" + $('#active_table').val() + "&updatestring=" + escape(updatestring), success: function(response){ if(updatestring){$("#ajaxTable").load("table.php");} else { $($('#ajaxtb')[0].rows[editTblRow].cells[editTblCell]).html(response); } editTblRow = null; editTblCell = null; } }); $($('#ajaxtb')[0].rows[editTblRow].cells[editTblCell]).removeClass('tdHover'); showDelete(editTblRow-1); } else { if(editTblRow==null && editTblCell==null){ if(fieldtype!='blob'){ $($('#ajaxtb')[0].rows[rowid].cells[cellid]).html('<input type="text" id="edit_box" class=\"edit_input\" value=\"' + id + '\" /> <div class=\"cell_opts\"><a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','save','','" + updatestring + "');" + '\">Save</a> - <a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','cancel');" + '\">Cancel</a></div>'); } else { $($('#ajaxtb')[0].rows[rowid].cells[cellid]).html('<textarea id="edit_box" class=\"edit_input\" value=\"' + id + '\" >' + id + '</textarea> <div class=\"cell_opts\"><a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','save','','" + updatestring + "');" + '\">Save</a> - <a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','cancel');" + '\">Cancel</a></div>'); } editTblRow = rowid; editTblCell = cellid; editSQLRowID = sqlrowid; editKey = key; cancelString = id; } else { if(editTblRow==rowid && editTblCell==cellid){ //We are currently editing this cell. Do nothing if clicked. if(editCancel==true){ editTblRow = null; editTblCell = null; } editCancel=false; return false; } else { //Load a new edit box on a new cell $($('#ajaxtb')[0].rows[editTblRow].cells[editTblCell]).hide().html(cancelString).fadeIn('slow'); if(fieldtype!='blob'){ $($('#ajaxtb')[0].rows[rowid].cells[cellid]).html('<input type="text" id="edit_box" class=\"edit_input\" value=\"' + id + '\" /> <div class=\"cell_opts\"><a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','save','','" + updatestring + "');" + '\">Save</a> - <a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','cancel');" + '\">Cancel</a></div>'); } else { $($('#ajaxtb')[0].rows[rowid].cells[cellid]).html('<textarea id="edit_box" class=\"edit_input\" value=\"' + id + '\" >' + id + '</textarea> <div class=\"cell_opts\"><a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','save','','" + updatestring + "');" + '\">Save</a> - <a href=\"javascript:return false;\" onclick=\"' + "editCell('','','','','','cancel');" + '\">Cancel</a></div>'); } editTblRow = rowid; editTblCell = cellid; editSQLRowID = sqlrowid; editKey = key; cancelString = id; } } } } DATABASE.PHP <?php /*Sevenscript <http://sevenscript.net> - Copyright (c) 2010 <info@sevenscript.net>*/ require_once('config.php'); $update_text = $_GET['text']; $sqlrowid = $_GET['sqlrowid']; $field = $_GET['field']; $updatestring = $_GET['updatestring']; if($updatestring){ $result = @mysql_query("SHOW COLUMNS FROM $table"); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $field_list .= $row['Field'] . ","; } $field_list = substr($field_list,0,-1); } $sql = "UPDATE $table SET $field= '$update_text' WHERE CONCAT_WS('',$field_list) = '$updatestring' LIMIT 1"; if(mysql_query ( $sql )){ echo $update_text; } } $sql = "UPDATE $table SET $field= '$update_text' WHERE _rowid = '$sqlrowid'"; if(mysql_query ( $sql )){ echo $update_text; } ?> DBFUNC.PHP <?php Header('Cache-Control: no-cache'); //IE Fix /*Sevenscript <http://sevenscript.net> - Copyright (c) 2010 <info@sevenscript.net>*/ require_once('config.php'); $action = $_GET['action']; $rowid = $_GET['rowid']; if($action=="delete"){ $sql = "DELETE FROM $table WHERE _rowid='$rowid' LIMIT 1"; mysql_query ( $sql ); } if($action=="new"){ //Insert a new row into the database mysql_query("INSERT INTO $table VALUES()"); $new_row = mysql_insert_id(); if(!$fields){ $result = @mysql_query("SHOW COLUMNS FROM $table"); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $fields[$row['Field']] = $row['Field']; $field_list .= $row['Field'] . ","; } $field_list = substr($field_list,0,-1); } } ?> <div class="tableBorder"> <table class="ajaxTable" cellpadding="0" cellspacing="0" border="0" id="ajaxtb"> <thead> <tr> <?php foreach($fields as $key => $val){ if($key == $get_order_by){ $imgsrc = "img/ajax/$direction.gif"; $sort = $direction; } else { $imgsrc = "img/ajax/arrows_updown.gif"; $sort = "DESC"; } echo "<th width=\"$width[$val]\">$val</th>"; } ?> <th> </th></tr> </thead> <tbody> <?php $sql = "SELECT count(*) AS num FROM $table $search_sql $order_by LIMIT $pageLimit"; $result = mysql_query ( $sql ); $rowCount = mysql_result($result,0,"num"); foreach($fields as $key => $val){ $select_fields .= $key . ","; } $select_fields = substr($select_fields,0,-1); $sql = "SELECT _rowid as rowid,$select_fields FROM $table $search_sql $order_by WHERE _rowid=$new_row LIMIT 1"; $row = mysql_query ( $sql ); while ( $result = mysql_fetch_array ( $row ) ) { echo "<tr class=\"tdOdd\" onmouseout=\"showDelete('$x');\" onmouseover=\"showDelete('$x');\">"; $fieldval=1; while($fieldval <= sizeof($fields)){ $fieldtype[$fieldval] = @mysql_field_type($row,$fieldval); $fieldval++; } $fieldpos=1; foreach($fields as $key => $val){ $filteredKey = htmlspecialchars(addslashes($result[$key])); echo "<td class=\"edit_cell\" style=\"$style[$key]\" id=\"$result[$key]\" onmouseover=\"$(this).addClass('tdHover');\" onmouseout=\"$(this).removeClass('tdHover');\" onclick=\"editCell(this.parentNode.rowIndex,this.cellIndex,'$result[rowid]','$key',this.innerHTML,'','$fieldtype[$fieldpos]','$result[updatestring]');\">" . $result[$key] . "</td>"; $fieldpos++; } ?> <td style="width: 28px; height: 28px;" onclick="delRow(this,'<?php echo $result['rowid']; ?>');"><div id="del_<?php echo $x; ?>" style="display: none;"><img src="img/ajax/delete_icon.gif" /></div></td></tr> <?php $x++; } ?> </tbody> <tfoot> <tr><td colspan="30"><input type="button" value="Done" onclick="loadTable();" /><input type="button" value="Cancel" onclick="cancelInsert('<?php echo $new_row; ?>');" /></td></tr> </tfoot> </table> <?php } ?> TABLE.PHP <?php Header('Cache-Control: no-cache'); //IE Fix //Sevenscript <http://sevenscript.net> - Copyright (c) 2009 Stuart Rutter <contact@sevenscript.net> require_once('config.php'); if(isset($_GET['table'])){ //$table = $_GET['table']; } if(!$fields){ $result = @mysql_query("SHOW COLUMNS FROM $table"); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $fields[$row['Field']] = $row['Field']; $field_list .= $row['Field'] . ","; } $field_list = substr($field_list,0,-1); } } $get_search = mysql_real_escape_string($_GET['search']); $get_start = mysql_real_escape_string($_GET['start']); $get_direction = mysql_real_escape_string($_GET['direction']); $get_order_by = mysql_real_escape_string($_GET['order_by']); if($get_search){ if(!$searchField){ $search_sql = " WHERE "; foreach($fields as $key=>$val){ $search_sql .= "$key LIKE '%$get_search%' OR "; } $search_sql = substr($search_sql,0,-4); } else { $search_sql = " WHERE $searchField LIKE '%$get_search%' "; } } if($get_start){ $start = $get_start; } else { $start = "0"; } if($get_direction){ $direction = $get_direction; } if($direction=="ASC"){$direction="DESC";} else { $direction="ASC";} if($get_order_by){ $order_by = " ORDER BY $get_order_by " . $direction; } else { $order_by = " "; } if($sortField && !$get_order_by){ $get_order_by = $sortField; $direction = $sortOrder; $order_by = " ORDER BY $get_order_by " . $direction; } ?> <div class="tableBorder"> <table class="ajaxTable" cellpadding="0" cellspacing="0" border="0" id="ajaxtb"> <thead> <tr> <?php foreach($fields as $key => $val){ if($key == $get_order_by){ $imgsrc = "img/ajax/$direction.gif"; $sort = $direction; } else { $imgsrc = "img/ajax/arrows_updown.gif"; $sort = "DESC"; } echo "<th width=\"$width[$val]\"><a href=\"#\" onclick=\"javascript:sortTable('$key','$sort');\">$val<img id=\"$key\" src=\"$imgsrc\" /></a></th>"; } ?> <th> </th></tr> </thead> <tbody> <?php $sql = "SELECT count(*) AS num FROM $table $search_sql $order_by LIMIT $pageLimit"; $result = mysql_query ( $sql ); $rowCount = mysql_result($result,0,"num"); foreach($fields as $key => $val){ $select_fields .= $key . ","; } $select_fields = substr($select_fields,0,-1); //Check if there is a primary key on the table $sql = "SELECT _rowid FROM $table"; $row= mysql_query ($sql); if(!$row){ $sql = "SELECT CONCAT_WS('',$field_list) as updatestring,$select_fields FROM $table $search_sql $order_by LIMIT $start, $pageLimit"; } else { $sql = "SELECT _rowid as rowid,$select_fields FROM $table $search_sql $order_by LIMIT $start, $pageLimit"; } $row = mysql_query ( $sql ); while ( $result = mysql_fetch_array ( $row ) ) { if ( $x&1 ){ echo "<tr class=\"tdOdd\" onmouseover=\"showDelete('$x');\" onmouseout=\"showDelete('$x');\">"; } else { echo "<tr class=\"tdEven\" onmouseout=\"showDelete('$x');\" onmouseover=\"showDelete('$x');\">"; } $fieldval=1; while($fieldval <= sizeof($fields)){ $fieldtype[$fieldval] = @mysql_field_type($row,$fieldval); $fieldval++; } $fieldpos=1; foreach($fields as $key => $val){ $filteredKey = htmlspecialchars(addslashes($result[$key])); echo "<td class=\"edit_cell\" style=\"$style[$key]\" id=\"$result[$key]\" onmouseover=\"$(this).addClass('tdHover');\" onmouseout=\"$(this).removeClass('tdHover');\" onclick=\"editCell(this.parentNode.rowIndex,this.cellIndex,'$result[rowid]','$key',this.innerHTML,'','$fieldtype[$fieldpos]','$result[updatestring]');\">" . $result[$key] . "</td>"; $fieldpos++; } ?> <td style="width: 28px; height: 28px;" onclick="delRow(this,'<?php echo $result['rowid']; ?>');"><div id="del_<?php echo $x; ?>" style="display: none;"><img src="img/ajax/delete_icon.gif" /></div></td></tr> <?php $x++; } $numberOfPages = ceil($rowCount / $pageLimit); ?> </tbody> <tfoot> <tr><td colspan="30"><h2><?php echo $rowCount . " Results - " . $numberOfPages . " Pages"; ?></h2></td></tr> </tfoot> </table> </div> <div class="pagination"> <?php $current_page = ceil($start / $pageLimit) + 1; $x=1; $start=0; if($current_page<=9){ while($x<=$numberOfPages){ if($x<=10){ if($current_page == $x){$class="paginationSelected";} else { $class="paginationNotSelected";} echo "<a href=\"javascript: void(0)\" class=\"$class\" onclick=\"javascript:gotoStart($start);\">$x</a> "; } if($x>10 && $x == $numberOfPages){ echo " ... <a href=\"javascript: void(0)\" class=\"$class\" onclick=\"javascript:gotoStart($start);\">$x</a> "; } $start = $start + $pageLimit; $x++; } } $x=1; if($current_page>=10){ $pageCounter = $current_page - 5; while($x<=10){ $pageNumber = $pageCounter * $pageLimit - $pageLimit; if($pageCounter<=$numberOfPages){ if($current_page == $pageCounter){$class="paginationSelected";} else { $class="paginationNotSelected";} echo "<a href=\"javascript: void(0);\" class=\"$class\" onclick=\"javascript:gotoStart($pageNumber);\">$pageCounter</a> "; } $pageCounter++; $x++; } } ?> <div class="newRowBtn"><input type="image" onclick="insertRow();" src="img/ajax/new_row_btn.png" value="Insert New Row" /></div> </div> <!-- <div class="tableBorder"> <table class="ajaxTable" cellpadding="0" cellspacing="0" border="0" id="ajaxtb"> <thead> <tr> <th></th> </tr> </thead> <tbody> <tr><td class="tdOdd"><div class="table_msg">Not Connected. Please use the login form.</div></td></tr> </tbody> </table> </div> --> And then my file process.php <?php include('core/config.php'); include ('includes/header.php'); if(!isset($_SESSION['user'])) { header('Location: ' . $url . '/login.php'); die(); } <div id="container"> <?php $con=mysqli_connect("localhost","user","pass!","db"); if(mysqli_errno($con)) { echo "Can't Connect to mySQL:".mysqli_connect_error(); } $fetch="SELECT ".$_SESSION['user']."_temp_table_1.UFP_CODE FROM ".$_SESSION['user']."_temp_table_1 LEFT OUTER JOIN InvManCen ON ".$_SESSION['user']."_temp_table_1.UFP_CODE = InvManCen.UFPCODE WHERE InvManCen.BLOCK = '2'"; $result = mysqli_query($con,$fetch); if(!$result) { echo "Error:".(mysqli_error($con)); } echo '<table class="center" align=center>'//.'<tr>'.'<td align="center">'. 'From Database'. '</td>'.'</tr>' ; echo '<tr>'.'<td>'.'<table>'.'<tr>'.'<td align=center>'.'Important Information'.'</td>'.'</tr>'; while($data=mysqli_fetch_row($result)) { echo ("<tr><td align=center><div class='alert-box notice'>Product with UFP Code $data[0] Is Blocked</div></td></tr>"); } echo '</table>'.'</td>'.'</tr>'.'</table>'; //<td>$data[2]</td><td>$data[3]</td><td>$data[4]</td> ?> <div class="ajaxTableHeader"></span> <label for="searchText">Search</label> <input type="text" id="searchText" class="tableSearch_input" name="searchText" value="" size="30" onkeyup="javascript:searchTable(this.value);" /> <div id="ajax_loading_div" style="display:none;"><img src="img/ajax/ajax-loader.gif" alt="Loading" /></div> </div> </br></br> <div id="ajaxTable"></div> </div> <button onclick="window.location.href='process3.php?&start=0&s=&f=&sort=id&ad=a'">Generate Quote</button> <button onclick="window.location.href='refresh.php'">Refresh</button> <?php include ('includes/footer.php'); ?> Is there any way we can make it so only one specific column is editable as at the moment all the values are editable.. when updating a column is there any way we can press enter rather than pressing the save button? Is it possible to get data from two tables. Like using a LEFT OUTER JOIN in mysql. Can someone help with this?
  17. <?php include("../../connect.php"); $burger=$row['event_name']; $query=mysql_query("CREATE TABLE $burger (id int(10) AUTO_INCREMENT,event_id char(50), name char(100))")or die (mysql_error()); ?> error : Incorrect table definition; there can be only one auto column and it must be defined as a key
  18. Hello, everyone. Can anybody help me, i'm trying to populate an HTML table with numbers in clockwise order, starting from last cell in the table then spiralling to the center. User inputs number of rows and columns, table is generated, but i'm lost at populating cells with numbers in clockwise order. Here's the code so far: <html> <head> <style> table{ border-collapse: collapse; } table, td{ border: 1px solid black; } td{ width: 50px; } tr{ height:50px; } </style> </head> <body> <div id="input"> <form action="table.php" method="post"> Input number of rows :<br> <input type="text" name="row"><br> Input number of columns:<br> <input type="text" name="column"><br> <input type="submit" name="submit" value="Ok"> </form> </div> <div id="output"> <?php $i = 0; $j = 0; echo "<table>"; for ($col = 0; $col < $_POST['column']; $col++) { echo "<tr>"; for ($row = 0; $row < $_POST['row']; $row++) { echo "<td>"; $i++; $array[$j] = $i; echo $array[$j]; $j++; echo "</td>"; } echo "</tr>"; } echo "</table>"; ?> </div> </body> </html> Array is there because i thought i could populate the table in desired order from array. Any suggestions, directions or links will be appreciated. Please help.
  19. Hello to everybody great community, I'm a beginner and I'm only familiar with basics of HTML, CSS and PHP. I'm working on small project and I could really use some help. So far I made web site with possibility to enter values into MySql table and to show this values(read it from table) on another page, As I sad would like to do something little more complex (at least is copmlex for me). What I want to do is something like very simple rating system: Choose ID via "select-choice" or similar line. So if I choose ID=JohnDoe, then all the grades I submit should be submitted only for this ID. I know how to make selection choice but I don't know how to connect it to save it to database/table. Only offered ID's should be available to select After ID is selected (JohnDoe) I would like 4 various grades options, each one is graded 1 to 5. Example: hair grade(1-5), clothing grade(1-5), education grade (1-5) etc. Option to submit and save grades into database, as I said it should be saved only for selected ID. On the new web page show results from table. Results should be presented separately for each ID. And in the last column average grade it should be shown. I have attached screenshot so you can see how I have pictured it. The main problem for me is how to submit grades to table and how to make sure grades are submited onyl to selected ID. Sorry for my English, hopefully I managed to explain problem. Many thanks in advance!
  20. Hi guys, before I get to the main part of my question, I first wanted to ask whether there is a maximum number of values you should store in an array. If for example you have 5000 boxes that people can choose from and eventually all 5000 boxes will be chosen, is it save to store all of the chosen boxes in an array? For example box1,box5,box7,box21 are already chosen, then someone chooses box2,box3,box4 and it adds to the same array, is that feasible with up to 5000 values in total? My thoughts on it were that it would probably be more feasible than giving each box it's own column!? Secondly, assuming the above is ok, how would I go about ensuring nobody could choose a box already chosen? Basically, if somebody chooses box3 and box4, how can I check that these don't exist in the column before adding them so they don't duplicate? Hope this makes some sense and isn't just gobblydeegook! Finally, if somebody in the Users table chooses box3 and box4 from SaleID5, what would be the best way of storing what they've chosen in the User table to use the data when they're viewing what they've got?! Many thanks in advance guys.
  21. Hello, I am querying a Mysql Database and displaying the results in a table. I need the results to Group twice and show totals. What I need is the results to group by the employee name, then under that name group by the date field. Then at the end of each date total up four of the columns that contain numbers. So the output would look like this: Employee Name Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 Employee Name Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 etc.... My code so far, I can not figure how to do the second grouping by date and put the totals in. mysql_select_db("time", $con); $result = mysql_query("SELECT * FROM data WHERE labor_date BETWEEN '$start' AND '$end' Group By user_name, labor_date Order by last_name ASC"); if (mysql_num_rows($result)==0) { echo "[warning_box]There are not any hours recorded for the time period that you chose. Please try again with a different set of dates.[/warning_box] "; } else { $current_user_name = false; while($row = mysql_fetch_array($result)) { // listing a new employee? Output the heading, start the table if ($row['user_name'] != $current_user_name) { if ($current_user_name !== false) echo '</table>'; echo '[divider_padding]';// if we're changing employee, close the table echo ' <h5>'.$row['last_name'].', '.$row['first_name'].'</h5>[minimal_table] <table> <tr> <th style="width:200px">Description</th> <th style="width:75px" class="tableleft">Job</th> <th style="width:75px" class="tableleft">Activity</th> <th style="width:290px" class="tableleft">Comments</th> <th style="width:64px" class="tableright">Hours</th> <th style="width:64px" class="tableright">OT</th> <th style="width:64px" class="tableright">Travel</th> <th style="width:63px" class="tableright">TOT</th> </tr>' ; $current_user_name = $row['user_name']; } // output the row of data echo '<tr> <td>'.$row['description'].'</td> <td class="tableleft">'.strtoupper($row['job']).'</td> <td class="tableleft">'.$row['activity'].'</td> <td class="tableleft">'.$row['comments'].'</td> <td class="tableright">'.$row['rthours'].'</td> <td class="tableright">'.$row['othours'].'</td> <td class="tableright">'.$row['trthours'].'</td> <td class="tableright">'.$row['tothours'].'</td> </tr> '; } echo '</table>[/minimal_table]'; // close the final table I am really stuck, Any help would be greatly appreciated!!!!
  22. right what i need to do is create 2 collumns for a html form, one of these is the ID and needs to be hidden and one collumn is full of options associated with these ID's the table which these two collumns are located on the database is called tbl_typesofbusiness and i just cant figure this out ive got the option box up but thats as far as i got i cant get two collumns up and they is no options in the option box, i just cant hack it ive been trying for a while and im confused to hell. <tr> <td>Type of Business:</td><td> <select name="typeofbusiness"> <?php $sql = sprintf("SELECT tbl_typesofbusiness.id, tbl_typesofbusiness.Agent FROM tbl_typesofbusiness")?></td> <td><span class="error">* <?php if (isset($errors['typeofbusiness'])) echo $errors['typeofbusiness']; ?></span></td> </tr> they is no errors on this code but i still cant seem to find a solution to it aswell theres only one record in the table at the moment which is called test1 with an id of 1. please help i just cant seem to hack it.
  23. Hello, I was making a login page with PHP and Mysql and have managed to debug all the errors, but the page says 'Wrong Username or Password' even though i have typed in the right password from the table. I was wondering if anyone could help me. Thanks I have 4 php files: main_login.php check_login.php login_success.php logout.php Here is all the code: main_login.php: <table> <tr> <form name="form1" method="post" action="check_login.php"> <td> <table> <tr> <td><strong>Login form: </strong></td> </tr> <tr> <td>UserName</td> <td>:</td> <td><input name="myusername" type="text" id="myusername"/></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="text" id="mypassword"/> </td> </tr> <tr> <td> </td> <td> </td> <td><input type="Submit" name="Submit" value="Login"/></td> </tr> </table> </td> </form> </tr> </table> <?php ?> check_login.php: <?php $host = "localhost"; $Username = "christopher"; $Password = "password"; $db_name = "test_db"; $tbl_name = "test"; //CONNECT TO SERVER mysql_connect("$host", "$Username", "$Password") or die("CANNOT CONNECT"); mysql_select_db("$db_name") or die("CANNOT SELECT DB"); //USERNAME AND PASSWORD FROM FORM $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; //SECURITY PROTECTION $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result = mysql_query($sql); $count = mysql_num_rows($result); $count = 1; if($count == 1){ session_register("myusername"); session_register("mypassword"); header("Location: http://localhost/login/2/login_success.php/"); } else { echo "Wrong Username Or Password"; } ?> login_success.php <?php session_start(); echo "login successful.."; if(!session_is_registered(myusername)){ header("location:main_login.php"); } ?> <html> <body> LOGIN SUCCESSFUL </body> </html> logout.php: <?php session_start(); session_destroy(); ?> check_login.php login_success.php logout.php main_login.php
  24. Hi, my code seemingly will not send the table data through email, the Table headers are sent fine, but anything after the while loop does not get sent, looking to remedy this issue.[ic]$to= 'mldecota@plymouth.edu'; <?php $to= 'mldecota@plymouth.edu'; $sub = "Hi"; $header = "Content-type: text/html"; $con = mysql_connect('localhost', 'sysop', 'Rotten210'); if (!$con){ die('could not connect' . mysql_error()) ; } $db_selected = mysql_select_db('mldecota', $con); if (!$db_selected) { die ('Borked ' . mysql_error()); } $result = mysql_query('SELECT * FROM data'); if (!$result) { die('Invalid query: ' . mysql_error()); } echo'completed succesfully'; echo "<table border='1'> <tr> <th>Date</th> <th>Time</th> <th>Machine</th> <th>Action</th> <th>User</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Date'] . "</td>"; echo "<td>" . $row['Time'] . "</td>"; echo "<td>" . $row['Machine'] . "</td>"; echo "<td>" . $row['Action'] . "</td>"; echo "<td>" . $row['USER'] . "</td>"; echo "</tr>"; } echo "</table>"; $msg = "<table border='1'> <tr> <th>Date</th> <th>Time</th> <th>Machine</th> <th>Action</th> <th>User</th> </tr>"; while($row1 = mysql_fetch_array($result)){ $msg.= "<tr>"; $msg.= "<td>" . $row1['Date'] . "</td>"; $msg.= "<td>" . $row1['Time'] . "</td>"; $msg.= "<td>" . $row1['Machine'] . "</td>"; $msg.= "<td>" . $row1['Action'] . "</td>"; $msg.= "<td>" . $row1['USER'] . "</td>"; $msg.= "</tr>"; } $msg .= "</table>"; mail($to,$sub,$msg,$header); mysql_close($con); ?> <?php phpinfo(); ?>
  25. How would I go about adding a search feature, css, and a hidden rows feature/next buttons to this table I have written in PHP? There are about 5000+ items listed in this table, so it's crucial that it's a fast search bar. Any help would be greatly appreciated. I was trying to use jquery but everything is messed up and the search + features don't show up. $fp=fopen("csv/inventory4.html",'w'); $write=fputs($fp,$html_body,strlen($html_body)); $i=0; $content = file("webinvt.txt"); foreach($content as $line) { $l=csv_split($line); if(!strstr($l[11],"SET")) { if($i==10) { $tmp = '<tr>'; $write=fputs($fp,$tmp,strlen($tmp)); $i=0; } $onhand = (int)$l[15]; $committed = (int)$l[16]; $avail = $onhand - $committed; $wcdate = substr($l[23],4); $eastdate = substr($l[19],4); if(strstr($l[1],"DISC")) { $html_body ='<tr "> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr>'; } else { $html_body ='<tr> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.