PHP - How Make Stat Table Structure And Show Earning
i am making online jobs portal where people send data after finish work and then we check that update thier earning stat
for that i am confused i want that if user earn 50$ per month we add those but when i next month add earning of that user that show show also 50$ and if i include 50 more there i can show last month earning one table and in one this month earn and in one table total earning till now and when USer earning total earning reach on 100$ or grater 100$ automatically show him 3 buttons where he can choose how he witdhraw the money and how much minimum $100 after once when he send us request for withdraw money those buttons again disapear and total balance - how much he requested us for withdraw so tell me how i make table strcute and which code i'll use Similar TutorialsHI All, I have noticed that when people show database structure on forums like this one, they have it as a table, like the following:
How do you create this? Hi, I am working on a project, where i want to add sub-sections within a section , and add once again adding sub-subsection under that section. How to make a table structure for that, any idea please Thanks,
Hello,
I have a table like this: CREATE TABLE days ( id INT AUTO_INCREMENT, daya INT, dayb INT, PRIMARY KEY (id) ); INSERT INTO days VALUES (70, 19, 18), (69, 20, 17), (68, 24, 25), (67, 19, 18), (66, 19, 17), (65, 17, 16);
$sql = "SELECT d1.id AS id1, d2.id AS id2, IF((d1.daya-d2.daya)=1,1,0) + IF((d1.daya-d2.dayb)=1,1,0) + IF((d1.dayb-d2.daya)=1,1,0) + IF((d1.dayb-d2.dayb)=1,1,0) AS tcount FROM days AS d1 , days AS d2 WHERE d1.id IS NOT NULL AND d2.id IS NOT NULL AND d1.id > d2.id"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "<tr><td>" . $row["id1"] . "</td><td>". $row["id2"] . "</td><td>" . $row["tcount"]. "</td></tr>"; } echo "</table>";
Id1 Id2 Count 50 49 1 50 48 0 49 48 0 50 47 1 49 47 1 48 47 0 50 46 1 49 46 1 48 46 0 47 46 1 50 45 1 49 45 1 48 45 0 47 45 1 46 45 1 I need to convert the table into this form: id1 goes down the first column, and id2 is in the first row. How can i do this, please? can you give me some help? thank you! id2 49 48 47 46 45 id1 50 1 0 1 1 1 49 0 1 1 1 48 0 0 0 47 1 1 46 1 45
I am still trying to fully comprehend table normalization and I'm not asking anyone to explain it bc it's not a simple thing to explain.
But I'm working on a football website that tracks players stats each week (catches, yards and touchdowns) and it seems like setting it up this way would make it the easiest (maybe laziest?) to retrieve data to display wherever I want...
tablecalled players with these fields:
playerid
playerfirstname
playerlastname
week1catches
week1yards
week1touchdowns
week2catches
week2yards
week2touchdowns
...
and so on 17 times till...
...
week17catches
week17yards
week17touchdowns
I know that is likely making most of you want to puke but if doing it this way makes it extremely easy to pull this info for display on the site, why is it so wrong? Is the problem that it's much slower than what I THINK is the proper way, ie...
table called players with these fields:
playerid
playerfirstname
playerlastname
AND
table called stats with these fields:
playerid
week
catches
yards
touchdowns
Again, not asking for an explanation of normalization, just if anyone has any quick reasons why the first way is as god awful as I fear it is, I'd appreciate the knowledge.
Thanks!
When having different levels of directories, using relative paths will not work anymore, for example: controller - authentication File 1: include('../../model/header.php') model File 2: header.php view File 3. style.css The header.php file includes the css file with a relative path, but the problem is it includes it as follows: ../view/style.css When now the header.php file gets included into File 1 in the folder "authentication", then the css file will not be accessible anymore, for it to be accessible you would have to go two directories up. In this sense my question is, what would be the proper path structure for a folder structure with multiple levels? Should I rather use absolute paths, I am not so prone of absolute path. What if the folders changes a bit, or the domain changes, or the location changes? This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=319414.0 I would like to know how to make my links show that it's active. For example if I click on a link that says overview then that link has to be highlighted. This is the code that I have: Code: [Select] <?php if (isset($this->_params['submenus']) && is_array($this->_params['submenus'])){ foreach ($this->_params['submenus'] as $submenu){ ?> <li class="active"><a href="<?php echo $this->get_uri("/{$submenu['controller']}/{$submenu['action']}") ?>" onclick="javascript:return setSubMenu(<?php echo $submenu['id'] ?>);"><?php echo strtoupper($submenu['name'])?></a></li> <?php } } ?> Unfortunately with this code all the links are selected as active. Hi, Sorry if this is in the wrong place. I really just need a search term to use for what i'm trying to do. I would like my buttons to appear pressed on each page. For example if you are on the home page the home button will appear pressed. If you are on the screenshots page the screenshots button will appear pressed. Pretty much i want my nav bar to display what page is being viewed. I'm using SMF forums and i've created an extension of my forum that i'm using on the root of my site. As far as i can tell i have the correct code added to the forum that should highlight the home button while on the home page. The part i'm missing is the code to add onto the home page. This is the code I have on the button. $buttons = array( 'overview' => array( 'title' => $txt['overview'], 'href' => 'http://www.wararmada.com', 'show' => true, 'sub_buttons' => array( 'alliance' => array( 'title' => $txt['alliance'], 'href' => $scripturl . '?action=overview;area=alliance', 'show' => true, ), This is the code i have in the language file. $txt['overview'] = 'overview'; I'm not sure what this is called. I don't know anything about php but so far i've been able to get by just using google but I don't really know how to search for this. Thanks for all the help! Hello, i'm trying to query mysql to show table contents, my code so far is this: Code: [Select] mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM codes"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); to show content: Code: [Select] <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"id"); $f2=mysql_result($result,$i,"code"); $f3=mysql_result($result,$i,"secret"); $f4=mysql_result($result,$i,"date"); $f5=mysql_result($result,$i,"ip"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> </tr>Now this shows all the content from the table, what i want to have is 2 scripts which should work like this: Script1 to show table contents: ID1, ID2, ID4, ID5, ID7, ID8 and so on. Script2 to show table contents: ID3, ID6, ID9 and so on. Basically one that shows only every 3rd and skips 1 and 2, and another one that skips every 3rd. Is this possible ? Thanks ! Can someone please tell me how to use the "SHOW FIELDS FROM $mytable" in php? I understand how the MySql works but need to get these fields back into an array in php. That is the part I am strruggling with.. I normally return rows of data from my table and use a while loop. Hello Guys.
I am having a trouble viewing a specific column content both in phpMyAdmin and console.It only shows a partial info about the contents inside that column.
I have attached a screenshot of this to give you a demonstration inside that link:
http://i59.tinypic.com/2n6ymqf.jpg
as you can see , the user picked hamburger ,steak and ground beef (and some more), but it seems that it stops showing it right in the middle of the word. Is there any limit for characters in this case?
What would be possible to figure that out please?
Thanks in advance..
Edited by osherdo, 17 December 2014 - 09:11 PM. Hi, okee so I'm new to everything that has to do with scripting, especially when it comes to PHP and stuff, but what is the best way to display information from a table on a page? I'm creating this site where users can post their events, but I want the Location to be based on the Location they inserted during the registration process, so that the location will be displayed directly. How am I able to do that? I've already got an login script, it looks like this: Code: [Select] <?php ob_start(); $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="whats_happening_db"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $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); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:membersarea.php?user=$myusername"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> Sorry if my English is terrible haha. Dante. hi, Instead giving its default on "Choose Process", I would like to display its process based on the value in database. How can I do it? Code: [Select] <?php require_once '../../connectDB.php'; require_once '../include/functions.php'; $sql = " SELECT * FROM tb_item ORDER BY itm_id asc"; $result = mysql_query($sql) or die(mysql_error()); ?> <form> <h1>Items</h1> <table width="75%" border="1" align="left" cellpadding="5" cellspacing="1"> <tr> <th width="100" align="left">Item ID</th> <th width="100" align="left">Parts</th> <th width="100" align="left">Sub-Process</th> <th width="100" align="left">Confirmation</th> </tr> <tr> <?php while ($row = mysql_fetch_array($result)) { extract($row); ?> <td><?php echo $itm_id; ?></td> <td><?php echo $itm_parts; ?></td> <td> <select name='cboSub' id='cbosub'> <option value='' selected>---- Choose Process ----</option> <?php createComboBox(); ?> </select> </td> <td> <a href='processItem.php?itm_id=<?php echo $itm_id; ?>'> <img src='../images/modify.png' width='20' height='20' alt='confirm'/> </a> </td> </tr> <?php }; ?> </table> </form> <?php /** * Create combo box for sub-process */ function createComboBox() { $sql = " SELECT * FROM tb_sub_process ORDER BY sub_id asc"; $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { extract($row); echo "<option value='$sub_id' $select>$sub_name</option>"; } } ?> I've attached an example of what basically the output will looks like. Any help are appreciated. Thanks in advance. Regards, Juz [attachment deleted by admin] Hi all, I am trying to make a members details section that can be updated. I want to be able to "SELECT * FROM users WHERE email='$email'" and then show the values that can be changed in a html drop down box with the selection that was made when the user registered already selected="selected"; You will be able to see what I am attempting to do below. <?php $sql = "SELECT manufacturer FROM table1 WHERE email=$'email'"; $result = mysqli_query($cxn,$sql); $row = mysqli_fetch_assoc($result); foreach manufacturer in table1 { if table1.manufacturer = table2.manufacturer { echo '<option name="manufacturer" selected="selected" value"$row['manufacturer']"</option>'; } else { echo '<option name="manufacturer" value"$row['manufacturer']"</option>'; } } ?> Here is my code. $display_block .= " <P>Showing posts for the <strong>$topic_title</strong> topic:</p> <table width=100% cellpadding=3 cellspacing=1 border=1> <tr> <th>AUTHOR</th> <th>POST</th> </tr>"; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); //add to display $display_block .= " <tr> <td width=35% valign=top>$post_owner<br>[$post_create_time]</td> <td width=65% valign=top>$post_text<br><br> <a href=\"replytopost.php?post_id=$post_id\"><strong>REPLY TO POST</strong></a></td> </tr>"; } //close up the table $display_block .= "</table>"; } ?> <html> <head> <title>Posts in Topic</title> </head> <body> <h1>Posts in Topic</h1> <?php print $dislplay_block; ?> </body> </html> I´ve reached to
<?php require_once('Connections/conexxion.php'); ?> <?php mysql_select_db($database_conexxion, $conexxion); $query_consulta = "SELECT venta,compra,taller,regula_mas,regula_menos,movimiento.id_item,sum(compra+regula_mas-venta-taller-regula_menos) as stock, cilindro, esfera FROM movimiento join item on item.id_item=movimiento.id_item join rx on rx.id_rx=item.id_rx join cilindro on cilindro.id_cil=rx.id_cil join esfera on esfera.id_esf=rx.id_esf GROUP BY movimiento.id_item ORDER BY esfera desc, cilindro desc"; $consulta = mysql_query($query_consulta, $conexxion) or die(mysql_error()); $row_consulta = mysql_fetch_assoc($consulta); $totalRows_consulta = mysql_num_rows($consulta); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>test</title> </head> <body> <?php echo "<table align=center>"; $columnes = 10; # Número de columnas (variable) if (($rows=mysql_num_rows($consulta))==0) { echo "<tr><td colspan=$columnes>No hay resultados en la BD.</td></tr> "; } else { echo "<tr><td colspan=$columnes>$rows Resultados </td></tr>"; } for ($i=1; $row = mysql_fetch_row ($consulta); $i++) { $resto = ($i % $columnes); # Número de celda del <tr> en que nos encontramos if ($resto == 1) {echo "<tr>";} # Si es la primera celda, abrimos <tr> echo "<td>$row[1]</td>"; if ($resto == 0) {echo "</tr>";} # Si es la última celda, cerramos </tr> } if ($resto <> 0) { # Si el resultado no es múltiple de $columnes acabamos de rellenar los huecos $ajust = $columnes - $resto; # Número de huecos necesarios for ($j = 0; $j < $ajust; $j++) {echo "<td> </td>";} echo "</tr>"; # Cerramos la última línea </tr> } mysql_close($connexion); echo "</table>"; ?> </body> </html> <?php mysql_free_result($consulta); ?>it "works", but results doesn´t start at number 1 but number 2 anyways, The intent of this table is to show the stock of a product, a lens, that has a range of Rx, we use to see this range this way, and show the stock this way would be very productive, but I can´t figure out how to achive it, any sugestion?? Edited by gralfitox, 16 December 2014 - 06:45 AM. I need to copy a table from one code to another. But I couldn't figure out how to do it properly. Just tried to copy code from one file to another but it doesn't work the same. I need to find where to change the code to show right columns.
https://easyupload.io/maoa9h - zipped cart.php (original code with right table) and review.php (the one that doesn't show right table)
We need to copy the table from cart.php: But it doesn't work. The quantity column doesn't show in review.php - as you can see here https://ibb.co/brP0yy1 Hello, i am coding a backend portal, this portal will have staff members lets call them 'M1' and each staff member will have a client 'C1' What is the best way to put this into a database? do i have a table for Staff? then a seperate table for Members? or one table consisting of staff, with the members details written into the staff's row? Hello, to start off I am very new to this and trying to learn as I go by using sample code and putting things together as I need them. I am working on a basic database editor that will make a select able list from a sql table. In this case, "Employees". Then, after I select a name from that list it gives me the option to alter that information and save it. What I am missing however, is the option to pre-fill what the database already has while in the edit part. The drop down menu only shows the Employee name. So when I select the name, only the EmpID variable is transferred to the next part. I want all fields pre-filled out by defining variables from the SQL table.
So I cant figure out how to call the database, then the table, Find the PRIMARY KEY (which is the EmpID) and create variables from (FirstName, LastName and Pay), but only for the EmpID that was slected before hand. How can I do this? Once I can make those variables, I can use them to pre-fill the text areas..
Thank you in advance. Also if needed I will post the code I have so far.
<html> <head> <title>Edit Employee</title> </head> <body> <?php $dbhost = 'localhost'; $dbuser = 'Labor'; $dbpass = '***********'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); // Check connection if(! $conn ) { die('Could not connect: ' . mysql_error()); } if(isset($_POST['save'])) { $EmpID = $_POST['EmpID']; $FirstName = $_POST['FirstName']; $LastName = $_POST['LastName']; $Pay = $_POST['Pay']; $OrgEmpID = $_POST['OrgEmpID']; $sql = "UPDATE Employees SET EmpID='$EmpID', FirstName='$FirstName', LastName='$LastName', Pay='$Pay' WHERE EmpID='$OrgEmpID'"; mysql_select_db('Labor'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not update data: ' . mysql_error()); } echo "Updated data successfully\n"; } else { if(isset($_POST['select'])) { $EmpID = $_POST['EmpID']; $FirstName = $_POST['FirstName']; $LastName = $_POST['LastName']; $Pay = $_POST['Pay']; $OrgEmpID = $_POST['EmpID']; echo ' Update Employee <form method="post" action="'.$_PHP_SELF.'"> <table width="400" border="0" cellspacing="1" cellpadding="2"> <tr> <td width="100">Employee ID: </td> <td><input name="EmpID" type="text" id="EmpID" value="'.$EmpID.'"></td> </tr> <tr> <td width="100">First Name: </td> <td><input name="FirstName" type="text" id="FirstName" value="'.$FirstName.'"></td> </tr> <tr> <td width="100">Last Name: </td> <td><input name="LastName" type="text" id="LastName" value="'.$LastName.'"></td> </tr> <tr> <td width="100">Hourly Pay: </td> <td><input name="Pay" type="text" id="Pay" value="'.$Pay.'"></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td width="100"> </td> <td> <input type="hidden" name="OrgEmpID" value="'.$OrgEmpID.'"> <input name="save" type="submit" id="save" value="Save"> </td> </tr> </table> </form> '; } else { ?> <form method="post" action="<?php $_PHP_SELF ?>"> <table width="400" border="0" cellspacing="1" cellpadding="2"> <tr> <td width="100">Select Employee to Edit</td> <td></td> </tr> <tr> <td width="100"> <select name="EmpID" id="EmpID"> <option value='EmpID' disabled='disabled' selected='selected'>Please select a name</option> <? mysql_select_db('Labor'); $result = mysql_query('SELECT EmpID, FirstName, LastName, Pay FROM Employees'); while ($row = mysql_fetch_array($result)) { echo '<option value="'.$row{"EmpID"}.'">'.$row{"FirstName"}.' '.$row{"LastName"}.'</option>'; } ?> </select> </td> <td> </td> </tr> <tr> <td width="100"> </td> <td> <input name="select" type="submit" id="select" value="Select"> </td> </tr> </table> </form> <?php } } ?> <br> <a href="index.php">Home</a> </body> </html> I'm have trouble getting my script to show images in a table across the screen. I want to show the picture and have the description shown below it. Right now it shows it in a column with the name next to it. Any help would be greatly appreciated. Thanks in advance. Below is the script. <?php include 'config1.php'; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE year = '1954'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 3; echo "<table>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div> <a><img src="<?php echo $tn; ?>"</a><a><?php echo $title; ?></a></div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> |