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 (Dreamweaver, Zend, 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. So I've followed this code, corrected about 12 error, talked to my hosting and I am so done. I have tried everything but the error won't go away. The code is pasted below. As it's really late any help would be appreciated that would make my day the next day... <?PHP //connect to server $connect = mysql_connect("localhost","cello10_import","brigite27"); //connection to database mysql_select_db("cello10_import"); //query the database $query = mysql_query("SELECT * FROM users WHERE cover_image = 'http://d1w7fb2mkkr3kw.cloudfront.net/assets/images/book/small/9781/2500/9781250038821.jpg' "); //fetch the results / convert into array WHILE($rows = mysql_fetch_array(query)): $cover_image = $rows['cover_image']; $title = $rows['title']; $author = $rows['author']; echo "$cover_image<br>$title<br>$author<br><br><br>"; endwhile; ?> The error experienced is: Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in /home/cello10/public_html/display.php on line 10 Thanks for your help
  2. I have created a system that uses an API to drop utility data into MSQL Server 2008. Once the data is in the db, a web app can query the data to create electric bills. Currently we are working with only one customer but are entertaining expansion and want to approach the growth from the best possible angle. Considering that all data is the same type of data but comes from different customers and sources, would it be best to maintain 1 database with all of the utility meter data streaming to it or would it be best to have a new data base with each customer? Also, assuming we keep it all in the same database, would it be best (assuming we are secure) to have all the individual customers data go to the same tables or have separate tables for separate customers. I'm pretty certain I know the answer but I'm a novice so that means nothing. Thank you for any help with this issue.
  3. I use PHPMyAdmin. I have to convert an InnoDB table to a MyISAM table. I then have to add a FULLTEXT index to two of the table's columns. Is this how I should proceed? 1) Backup table by exporting its contents. 2) Go to "Relation view" and drop foreign key constraints. 3) ALTER TABLE `table_name` ENGINE = MyISAM; 4) ALTER TABLE `table_name` ADD FULLTEXT index_name (col1,col2); Is that it? Is it safe? Note that the table contains approximately 3,500 rows.
  4. I have problem how to saving all my record. when I save I just got 1 record saved in mySQL and it the last record on that table. Here is my code = <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO thasil (nrp, nama, pangkat, mgolongan, mtes_fisik, mkemampuan, hasil) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['nrp'], "int"), GetSQLValueString($_POST['nama'], "text"), GetSQLValueString($_POST['pangkat'], "text"), GetSQLValueString($_POST['mgolongan'], "int"), GetSQLValueString($_POST['mtes_fisik'], "double"), GetSQLValueString($_POST['mkemampuan'], "double"), GetSQLValueString($_POST['hasil'], "double")); mysql_select_db($database_stok, $stok); $Result1 = mysql_query($insertSQL, $stok) or die(mysql_error()); $insertGoTo = ""; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_stok, $stok); $query_anggotaset = "SELECT * FROM tanggota ORDER BY nrp ASC"; $anggotaset = mysql_query($query_anggotaset, $stok) or die(mysql_error()); $row_anggotaset = mysql_fetch_assoc($anggotaset); $totalRows_anggotaset = mysql_num_rows($anggotaset); mysql_select_db($database_stok, $stok); $query_bobotset = "SELECT * FROM tbobot"; $bobotset = mysql_query($query_bobotset, $stok) or die(mysql_error()); $row_bobotset = mysql_fetch_assoc($bobotset); $totalRows_bobotset = mysql_num_rows($bobotset); $crMax = mysql_query("SELECT min(Golongan) as minK1, max(tes_fisik) as maxK2, max(kemampuan) as maxK3 FROM tanggota"); $max = mysql_fetch_array($crMax); $no=1; ?> <?php include ('header.php') ?> <div id="conten-wrapper"> <div id="conten"> <h1> Normalisasi Anggota Kesamaptaan </h1> <p> <a href="cetak.php"><img src="../images/btn_list.png" height="20"/> >>> Lihat & Cetak Hasil Akhir Perangkingan</a></p> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table border="1" cellpadding="3" cellspacing="1"> <tr> <td>no</td> <td>nrp</td> <td>nama</td> <td>pangkat</td> <td>C1 Golongan</td> <td>C2 tes_fisik</td> <td>C3 kemampuan</td> <td>hasil</td> </tr> <?php do { $hasil= round (($max['minK1']/$row_anggotaset['Golongan']*$row_bobotset['golongan']+ $row_anggotaset['tes_fisik']/$max['maxK2']*$row_bobotset['tes_fisik']+ $row_anggotaset['kemampuan']/$max['maxK3']*$row_bobotset['kemampuan']),2) ; ?> <tr> <td><?php echo $no; $no++;?></td> <td><input type="text" name="nrp" value="<?php echo $row_anggotaset['nrp']; ?>" readonly/></td> <td><input type="text" name="nama" value="<?php echo $row_anggotaset['nama']; ?>" readonly/></td> <td><input type="text" name="pangkat" value="<?php echo $row_anggotaset['pangkat']; ?>" size="4" readonly/></td> <td><input type="text" name="mgolongan" value="<?php echo round ($max['minK1']/$row_anggotaset['Golongan'] *$row_bobotset['golongan'],2); ?>" size="2" readonly/></td> <td><input type="text" name="mtes_fisik" value="<?php echo round ($row_anggotaset['tes_fisik']/$max['maxK2'] *$row_bobotset['tes_fisik'],2); ?>" size="2" readonly/></td> <td><input type="text" name="mkemampuan" value="<?php echo round ($row_anggotaset['kemampuan']/$max['maxK3'] *$row_bobotset['kemampuan'],2); ?>" size="3" readonly/></td> <td><input type="text" name="hasil" value="<?php echo $hasil ?>" size="2" readonly/></td> </tr> <?php } while ($row_anggotaset = mysql_fetch_assoc($anggotaset));?> <tr valign="baseline"> <td colspan="8" align="right" nowrap="nowrap"><input type="submit" value="Insert record" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> </div> <?php include ('footer.php') ?> </body> </html> <?php mysql_free_result($anggotaset); mysql_free_result($bobotset); ?>
  5. Hello everyone, i'm Osiris and i'm stuck with this PHP/HTML code, i'm fairly new at this so this might be a dumb question. i have a database, but i want to output all data into a table from the database using HTML codes. i had it so far that i could outpust the info in just plain text but it doesn't output in the HTML table. Can anyone see what i did wrong? This is my PHP code its in the body section <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } $sql = 'SELECT `Name`, `Color`, `Type`, `Subtype`, `Power`, `Toughness`, `Manacost`, `Rarity`, `Expansion`, `Foil`, `Stock` FROM `mtgtabel`'; mysql_select_db('mtgstock'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } echo '<table class=mytable>'; echo "<tr><th >Name</th><th >Color</th><th >Type</th><th >Sub Type</th><th >Power</th><th >Toughness</th><th >Converted mana cost</th><th >Rarity</th><th >Expansion</th><th >Foil</th><th >Stock</th></tr>"; while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "<tr><td>"; echo $row['Name'] echo "</td><td>"; echo $row['Color']; echo "</td><td>"; echo $row['Type']; echo "</td><td>"; echo $row['Subtype']; echo "</td><td>"; echo $row['Power']; echo "</td><td>"; echo $row['Toughness']; echo "</td><td>"; echo $row['Manacost']; echo "</td><td>"; echo $row['Rarity']; echo "</td><td>"; echo $row['Expansion']; echo "</td><td>"; echo $row['Foil']; echo "</td><td>"; echo $row['Stock']; echo "</td></tr>"; } echo "</table>"; mysql_close($conn); ?> Thanks in advance!
  6. How to display items like bottom table? And here is the code <? print" <table style=\"width:100%\" class=\"tableList\"> <tr> <th style=\"width:35%\">Prize Name</th> <th style=\"width:12%\">Amount</th> <th style=\"width:12%\">Points</th> <th style=\"width:12%\">Available</th> <th style=\"width:12%\">Redeemed</th> <th style=\"width:17%\">Action</th> </tr>"; $giftCardQuery = 'SELECT currency, amount, pointsPrice, instant_gift_cards.id, instant_gift_cards.giftCardName, instant_gift_cards.giftCardImage FROM instant_gift_card_codes INNER JOIN instant_gift_cards ON (instant_gift_card_codes.giftCardId = instant_gift_cards.id) WHERE instant_gift_cards.status = :cardStatus ORDER BY instant_gift_cards.dateCreated DESC'; $giftCard = $db->prepare($giftCardQuery); $giftCard->bindValue(':cardStatus', 'Enabled', PDO::PARAM_STR); $giftCard->execute(); if($giftCard->rowCount() > '0'){ while($giftCardRow = $giftCard->fetch(PDO::FETCH_ASSOC)){ $giftCardsAvailableQuery = 'SELECT count(*) FROM instant_gift_card_codes WHERE currency = :currency AND amount = :amount AND pointsPrice = :pointsPrice AND giftCardId = :id AND status = :status'; $giftCardsAvailable = $db->prepare($giftCardsAvailableQuery); $giftCardsAvailable->bindParam(':currency', $giftCardRow['currency'], PDO::PARAM_STR); $giftCardsAvailable->bindParam(':amount', $giftCardRow['amount'], PDO::PARAM_STR); $giftCardsAvailable->bindParam(':pointsPrice', $giftCardRow['pointsPrice'], PDO::PARAM_STR); $giftCardsAvailable->bindParam(':id', $giftCardRow['id'], PDO::PARAM_INT); $giftCardsAvailable->bindValue(':status', 'Available', PDO::PARAM_STR); $giftCardsAvailable->execute(); $gCardsAvailable = $giftCardsAvailable->fetch(PDO::FETCH_COLUMN); $giftCardsRedeemedQuery = 'SELECT count(*) FROM instant_gift_card_codes WHERE currency = :currency AND amount = :amount AND pointsPrice = :pointsPrice AND giftCardId = :id AND status = :status'; $giftCardsRedeemed = $db->prepare($giftCardsRedeemedQuery); $giftCardsRedeemed->bindParam(':currency', $giftCardRow['currency'], PDO::PARAM_STR); $giftCardsRedeemed->bindParam(':amount', $giftCardRow['amount'], PDO::PARAM_STR); $giftCardsRedeemed->bindParam(':pointsPrice', $giftCardRow['pointsPrice'], PDO::PARAM_STR); $giftCardsRedeemed->bindParam(':id', $giftCardRow['id'], PDO::PARAM_INT); $giftCardsRedeemed->bindValue(':status', 'Redeemed', PDO::PARAM_STR); $giftCardsRedeemed->execute(); $gCardsRedeemed = $giftCardsRedeemed->fetch(PDO::FETCH_COLUMN); if($giftCardRow['giftCardImage']){ $nameOrImage = '<img src="./images/giftcardrewards/'.$giftCardRow['giftCardImage'].'" alt="'.$giftCardRow['giftCardName'].'" title="'.$giftCardRow['giftCardName'].'">'; }else{ $nameOrImage = $giftCardRow['giftCardName']; } if($gCardsAvailable == '0'){ $redeemAction = 'Out of Stock'; } elseif($userInfo['currentPoints'] < $giftCardRow['pointsPrice']){ $needed = $giftCardRow['pointsPrice'] - $userInfo['currentPoints']; $redeemAction = 'You need '.$needed.' point(s)'; } elseif($userInfo['currentPoints'] >= $giftCardRow['pointsPrice']){ $redeemAction = '<input type="button" value="Redeem" onclick="if(confirm(\'Are you sure to redeem this prize?\')){location.href=\'index.php?do=instantGiftCards&action=redeem&cardId='.$giftCardRow['id'].'&amount='.$giftCardRow['amount'].'\';}">'; } print" <tr> <td>".$nameOrImage."</td> <td style=\"text-align:center\">".$giftCardRow['currency'].$giftCardRow['amount']."</td> <td style=\"text-align:center\">".$giftCardRow['pointsPrice']."</td> <td style=\"text-align:center\">".$gCardsAvailable."</td> <td style=\"text-align:center\">".$gCardsRedeemed."</td> <td style=\"text-align:center\">".$redeemAction."</td> </tr>"; } }else{ print" <tr> <td colspan=\"4\" style=\"text-align:center;color:#2B1B17;padding:15px 0\">No prizes added.</td> </tr>"; } print" </table>"; ?>
  7. 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
  8. 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}
  9. 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.
  10. 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)
  11. 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).
  12. 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>
  13. 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>
  14. 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
  15. 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>'; } ?>
  16. 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.
  17. 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
  18. 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!
  19. 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.
  20. 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.
  21. 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)
  22. 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?
  23. <?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
  24. 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.
  25. 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!
×
×
  • 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.