PHP - Need Help With Displaying Mysql Data
Hey guys have been trying to get this script to work for a while now, i am new to php and mysql so i am sure i am missing something simple. I have DB setup and need to pull data based on the key item code and get the following
I want to get the fields item_code description allergy_statement useable_units region_availability order_lead_time ingredients for item_code 12-100 LITERALLY 12-100, no range, but like i said before i am really new to php and mysql. I have 1187 items that when a user clicks a link in search results it takes them to the product details page for that item code All that data is in my database just can't figure out how to get it out of the database. Is this even the right script to achieve that result. here is the code to get the data from database Code: [Select] <?php require_once('includes/mysql_connect_nfacts_ro.php'); $query = "SELECT item_code, description, allergy_statement, useable_units, region_availability, order_lead_time, ingredients " . "FROM products " . "WHERE item_code = '12-100' "; $resuts = mysql_query($query) or die(mysql_error()); ?> And need to display the data like so : Code: [Select] <td width="715" align="center" valign="top"> <h1>Product Details</h1> <h3>DISPLAY description HERE</h3> <table width="420" border="0"> <td class="ingreg"> </td> </table> <h5>Item Number</h5> <table width="420" border="0"> <tr> <td class="ingreg">DISPLAY ITEM_CODE HERE</td> </tr> </table> <h3>Ingredients:</h3> <table width="420" border="0"> <tr> <td class="ingreg">DISPLAY INGREDIENTS HERE</td> </tr> </table> <h4>Allergy Statement:</h4> <table width="420" border="0"> <tr> <td class="ingreg">DISPLAY Allergy Statement HERE</td> </tr> </table> <h4>Useable Units Per Package:</h4> <table width="420" border="0"> <tr> <td class="ingreg">DISPLAY Useable Units Per Package HERE</td> </tr> </table> <h4>Region Availability: </h4> <table width="420" border="0"> <tr> <td class="ingreg">&DISPLAY ITEM_CODE HERE</td> </tr> </table> <h4>Order Lead Time:</h4> <table width="420" border="0"> <tr> <td class="ingreg">&DISPLAY order lead time HERE</td> </tr> </table> <p> </p> <div align="right"></div></td> </tr> </table> how do i get data in database to display where i need it to? Can any one shine some light on this Similar TutorialsOk... I need some help - I want to show a players balance in a game beside there name (Balance is in mysql database)I can do that but... - I also want to show if there online or offline at the same time( This is stored in a different database) I have the code which says whether they are online or offline <?PHP // Conect to the Mysql Server $connect = mysql_connect("localhost","scswccla_bukkit","********"); //connect to the database mysql_select_db("scswccla_bukkit"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); //title echo "<font size='100'>NovaCraft Users</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='black'>|Online|<br><font color='green'>$users</font></font><br>"; endwhile; //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 0"); //title echo "<font color='black'>|Offline|</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='red'>$users</font><br>"; endwhile; ?> Here is the page: www.scswc.com/Offline_Users.php displaying that But I want to Create something like this: Nocvacraft Players |Online| Name:Player Balance:$20 |Offline| Name:Player Balance:$15 Here is what I have tried: <?PHP // Conect to the Mysql Server $connect = mysql_connect("localhost","scswccla_bukkit","**********"); //connect to the database mysql_select_db("scswccla_bukkit"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); $query2 =mysql_query("SELECT * FROM iBalances WHERE player = $users"); //title echo "<font size='100'>NovaCraft Users</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query) $rows2 = mysql_fetch_array($query2)): $users = $rows['name']; $balance = $rows2['balance']; echo "<font color='black'>|Online|<br><font color='green'>Name:$usersBalance:$balance</font></font><br>"; endwhile; //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 0"); //title echo "<font color='black'>|Offline|</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='red'>$users</font><br>"; endwhile; ?> I know I am trying to use a variable before it is been set - but if I don't how I have tried this as well... <?PHP // Conect to the Mysql Server $connect = mysql_connect("localhost","scswccla_bukkit","**********"); //connect to the database mysql_select_db("scswccla_bukkit"); //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 1"); //title echo "<font size='100'>NovaCraft Users</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='black'>|Online|<br><font color='green'>Name:$users</font></font><br>"; endwhile; //query the database $query = mysql_query("SELECT * FROM users_online WHERE online = 0"); //title echo "<font color='black'>|Offline|</font><br>"; // fetch the results / convert into an array WHILE($rows = mysql_fetch_array($query)): $users = $rows['name']; echo "<font color='red'>$users</font><br>"; endwhile; $query = mysql_query("SELECT * FROM iBalances WHERE player = $users"); WHILE($rows = mysql_fetch_array($query)): $balance = $rows['balance']; echo "<font color='red'>$users $balance</font><br>"; endwhile; // ?> Can you use variables in mysql_query()?Is that why it isn't working? This is my first php script so if I need to give you more information for you to help me just tell me Thanks Here is database pictures iBalances users_online So i pull some records out of a mysql table and i want to display them in 5 even columns. I'm not entirely sure how to do the math & logic to accomplish this. The pull is simple $qry = "SELECT DIST_PART_NUM FROM $tablename"; $sql = mysql_query($qry) or die(mysql_error()); while($res = mysql_fetch_assoc($sql)) { // CREATE 5 even columns here. } so let's say i just retrieved 5,000 part numbers, i'd like to display then in a table of 5 columns with 1000 records per column. This is easy math, but i need the script to automatically figure out the #'s. Also the tricky part is that i dont want to display the part numbers like so 11111 22222 33333 44444 55555 66666 77777 88888 99999 00000 but rather 11111 44444 77777 22222 55555 88888 33333 66666 99999 00000 the remainder if there is one can go in the last column or whatever is easier. I'd tried googling this, but it's not easy to phrase what i'm looking for. Thanks for the help. PS: I'm not looking to copy and paste code, if possible please explain your way so that i can learn the logic. I am querying my database to show the visit statistics for a particular week and it shows the number of visits for the countries, but does not display the country name.
I have proved that the MySQL works by going into phpMyAdmin and pasting the query into SQL query tab, replacing the POST with 1, for week 1.
I can't see why it is not displying the country.
Here is the code:
<?php include('connect_visits.php'); doDB7(); $WVisit_data="SELECT WeekNo15.WNo, WeekNo15.WCom, Countries.Country, Countries.CID, ctryvisits15.CVisits FROM ctryvisits15 LEFT JOIN Countries ON ctryvisits15.country = Countries.CID LEFT JOIN WeekNo15 ON ctryvisits15.WNo = WeekNo15.WNo WHERE ctryvisits15.WNo = '{$_POST['WeekNo']}' ORDER BY ctryvisits15.CVisits DESC"; $WVisit_data_res = mysqli_query($mysqli, $WVisit_data) or die(mysqli_error($mysqli)); $display_block =" <table width=\"20%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"white\" > <tr> <th>Country</th> <th>Visits</> </tr>"; while ($WV_info = mysqli_fetch_array($WVisit_data_res)){ $Ctry = $WV_info['country']; $Visits = $WV_info['CVisits']; //add to display $display_block .=" <tr> <td width=\"10%\" valign=\"top\">".$Ctry."<br/></td> <td width=\"5%\" valign=\"top\">".$Visits."<br/></td> "; } mysqli_free_result($WVisit_data_res); mysqli_close($mysqli); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- Design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License Name : Yosemite Description: A two-column, fixed-width design with dark color scheme. Version : 1.0 Released : 20091106 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>1066 Cards 4U - Stats for country</title> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <div id="menu"> <ul> <li class="current_page_item"><a href="index.php">Home</a></li> <li><a href="Links.html">Links</a></li> <li><a href="Verse_Menu.html">Verses</a></li> <li><a href="Techniques.html">Techniques</a></li> <li><a href="blog.php">Blog</a></li> <li><a href="Gallery.html">Gallery</a></li> <li><a href="contact.html">Contact</a></li> <li><a href="AboutUs.html">About Us</a></li> <li><a href="stats1.html">Stats</a></li> </ul> </div><!-- end #menu --> <div id="header"> <div id="logo"> <h1><a href="http://www.1066cards4u.co.uk">1066 Cards 4U</a></h1> </div><!-- end #wrapper --> </div><!-- end #header --> <div id="page"> <div id="page-bgtop"> <div id="page-bgbtm"> <div id="content"> <h3>Statistics for Week Commencing <? echo $WkCom; ?> in 2015</h3> <div id="table"> <?php echo $display_block; ?></div> </div><!-- end #content --> </body> </html>Can you help please? Edited by rocky48, 07 January 2015 - 07:33 AM. Hi guys. I'm trying to build a games site for a friend. Currently, the front-end (HTML/CSS) of the site is done. Now, I want to make a way for him to easily add games to the site. Ideally, I'd like to make a database with the following columns: ID, Name, Category, Link, Thumbnail_Link. So, those would be the ID, name of the game, the category, a link to the game, and a link to the 50x50 thumbnail image respectively. Then, using PHP, I'd like to call the first x number (not sure what it will be yet, let's say 50) and make format it as a grid in the following way: There's the thumbnail image followed by the game name, and they're all a clickable link to the game URL. Is this possible? How would I go about doing this? I've already set up a database for a login module to the site, so each page has already opened a connection to the MySQL database. However, I've only ever done basic PHP for mail forms and am otherwise extremely new to it, and am especially new to MySQL. Could anyone walk me through how to do this or even give me a quick example script to work off of? Thanks, any of your time is greatly appreciated! I have a table in a mysql database with 5 columns, id, Name, Wifi, Bluetooth, GPS, with rows that are for example 1, Galaxy S2, yes, yes, yes. So basically i want to build a form that has check boxes (3 checkboxes for wifi bluetooth and GPS respectively) that once selected will query the database depending on which check boxes are selected. I have made the form but need to know what to put in the filter.php to make the results be displayed accordingly. Ideally if anyone knows how i would want it so the results were shown on the same page which i believe u need to use ajax to happen but any help on how to show the results will be greatful. the code for the form i have made is as follows: Code: [Select] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>test</title> </head> <body> <form action="filter.php" method="post"> <INPUT TYPE=CHECKBOX NAME="option[]" VALUE="Wifi" id="r1">Wifi <INPUT TYPE=CHECKBOX NAME="option[]" VALUE="Bluetooth" id="b1">Bluetooth <INPUT TYPE=CHECKBOX NAME="option[]" VALUE="GPS" id="g1">GPS <input type="submit" name="formSubmit" value="Submit" /> </form> </body> </html> im not sure on how to make the filter.php page but i do have this code for displaying the all the data but i want to kno how to make it only display the data from the choices on the checkboxes Code: [Select] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>pls work</title> </head> <body> <?php function h($s) { echo htmlspecialchars($s); } mysql_connect("localhost", "root", "") or die (mysql_error()); mysql_select_db("project") or die (mysql_error()); $result= mysql_query('SELECT * FROM test') or die('Error, query failed'); ?> <?php if (mysql_num_rows($result)==0) { ?> Database is empty <br/> <?php } else { ?> <table> <tr> <th></th> <th>Name</th> <th>Wifi</th> <th>Bluetooth</th> <th>GPS</th> </tr> <?php while ($row= mysql_fetch_assoc($result)) { ?> <tr> <td> <a href="uploaded-images/<?php h($row['Name']); ?>.jpg"> <img src="uploaded-images/<?php h($row['Name']); ?>.jpg" alt="test"/> </a> </td> <td><a href="textonly.html"><?php h($row['Name']); ?></a></td> <td><?php h($row['Wifi']); ?></td> <td><?php h($row['Bluetooth']); ?></td> <td><?php h($row['GPS']); ?></td> </tr> <?php } ?> </table> <?php } ?> </body> </html> Hi all, I'm trying to display a form based on a dropd own selection. The drop down is propagated from a database query. I have the drop down list displaying, but when I click submit, I can't get the result to display. Code: [Select] $sql="SELECT id, company_name FROM webprojects ORDER BY company_name ASC"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $company_name=$row["company_name"]; $options.="<OPTION VALUE=\"$id\">".$company_name; } ?> <!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>PHP Dynamic Drop Down Menu</title> </head> <body> <form id="form1" name="form1" method="post" action="selected.php"> <SELECT NAME=id> <OPTION VALUE=0>Choose <?=$options.="<OPTION VALUE=\"$id\">".$company_name.'</option>';?> </SELECT> <label> <input type="submit" name="submit" id="submit" value="Submit" /> </label> </form> </body> </html> Any help is greatly appreciated Hi There! Hopefully someone can help. I'm looking for some php script that allows me to display mysql table data in alternating row colors (eg 5 columns and 500 rows). I would also like to add pagination and limit number of rows displayed at a time to e.g. 50. If possible I'd like to be able to sort asc/desc using titles(links) at the top of the displayed data. Hopefully someone may have a script like this that also shows the mysql connection code (sample host, pass, user etc...) - a working php file so to speak that I can edit. Would really appreciate the help. If you could recommend some software or a wizard that could generate the php code for me I would really appreciate it too! THANKS! Hello everyone, I begin in everything web related but I have been programming for years. I tried to code something simple : small Mysql DB (works fine) and to begin a search bar to browse data. I adapted a code that I understood provided here : https://www.cloudways.com/blog/live-search-php-mysql-ajax/. Base principle is simple : as you type in your query, it will pass the text to script.js that will forward this request to ajax.php file. In the ajax.php, a javascript function named “fill()” will pass the fetched results. This function will also display the result(s) into “display” div in the “search.php” file. The problem is that when I type anything it displays, below the search bar, at the moment I type a character: Quote
'; //Fetching result from database. while ($Result = MySQLi_fetch_array($ExecQuery)) { ?> ")'>
instead of the actual answer from my database (no error in the browser console). I tested the SQL query + the user I provide and everything seems fine. Any clue what could be the root cause ? I strongly suspect a mistake in the code as I already corrected one (script.js instead of scripts.js) but I really cannot figure out where. Thanks in advance,
problematic code (ajax.php):
<?php //Including Database configuration file. include "db.php"; //Getting value of "search" variable from "script.js". if (isset($_POST['search'])) { //Search box value assigning to $Name variable. $Name = $_POST['search']; //Search query. $Query = "SELECT Name FROM search WHERE Name LIKE '%$Name%' LIMIT 5"; //Query execution $ExecQuery = MySQLi_query($con, $Query); //Creating unordered list to display result. echo ' <ul> '; //Fetching result from database. while ($Result = MySQLi_fetch_array($ExecQuery)) { ?> <!-- Creating unordered list items. Calling javascript function named as "fill" found in "script.js" file. By passing fetched result as parameter. --> <li onclick='fill("<?php echo $Result['Name']; ?>")'> <a> <!-- Assigning searched result in "Search box" in "search.php" file. --> <?php echo $Result['Name']; ?> </li></a> <!-- Below php code is just for closing parenthesis. Don't be confused. --> <?php }} ?> </ul>
Hi, I'm trying to make a dynamic html table to contain the mysql data that is generated via php. I'm trying to display a user's friends in a table of two columns and however many rows, but can't seem to figure out what is needed to make this work. Here's my code as it stands: Code: [Select] <?php //Begin mysql query $sql = "SELECT * FROM friends WHERE username = '{$_GET['username']}' AND status = 'Active' ORDER BY friends_with ASC"; $result = mysql_query($sql); $count = mysql_num_rows($result); $sql_2 = "SELECT * FROM friends WHERE friends_with = '{$_GET['username']}' AND status = 'Active' ORDER BY username ASC"; $result_2 = mysql_query($sql_2); $count_2 = mysql_num_rows($result_2); while ($row = mysql_fetch_array($result)) { echo $row["friendswith"] . "<br>"; } while ($row_2 = mysql_fetch_array($result_2)) { echo $row_2["username"] . "<br>"; } ?> The above simply outputs all records of a user's friends (their usernames) in alphabetical order. The question of how I'd generate a new row each time a certain amount of columns have been met, however, is beyond me. Anyone know of any helpful resources that may solve my problem? Thanks in advance =) Hello to all, I have problem figuring out how to properly display data fetched from MySQL database in a HTML table. In the below example I am using two while loops, where the second one is nested inside first one, that check two different expressions fetching data from tables found in a MySQL database. The second expression compares the two tables IDs and after their match it displays the email of the account holder in each column in the HTML table. The main problem is that the 'email' row is displayed properly while its while expression is not nested and alone(meaning the other data is omitted or commented out), but either nested or neighbored to the first while loop, it is displayed horizontally and the other data ('validity', 'valid_from', 'valid_to') is not displayed.'
Can someone help me on this, I guess the problem lies in the while loop? <thead> <tr> <th data-column-id="id" data-type="numeric">ID</th> <th data-column-id="email">Subscriber's Email</th> <th data-column-id="validity">Validity</th> <th data-column-id="valid_from">Valid From</th> <th data-column-id="valid_to">Valid To</th> </tr> </thead> Here is part of the PHP code:
<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo ' <tr> <td>'.$row["id"].'</td> '; while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) { echo ' <td>'.$row1["email"].'</td> '; } if($row["validity"] == 1) { echo '<td>'.$row["validity"].' month</td>'; }else{ echo '<td>'.$row["validity"].' months</td>'; } echo ' <td>'.$row["valid_from"].'</td> <td>'.$row["valid_to"].'</td> </tr>'; } ?>
Thank you. This could be PHP or MySql so putting it in PHP forum for now... I have code below (last code listed) which processes a dynamically created Form which could have anywhere from 0 to 6 fields. So I clean all fields whether they were posted or not and then I update the mySQL table. The problem with this code below is that if, say, $cextra was not posted (i.e. it wasnt on the dynamically created form), then this code would enter a blank into the table for $cextra (i.e. if there was already a value in the table for $cextra, it gets overwritten, which is bad). What is the best way to handle this? I'm thinking i have to break my SQL query into a bunch of if/else statements like this... Code: [Select] $sql = "UPDATE cluesanswers SET "; if (isset($_POST['ctext'])){ echo "ctext='$ctext',"; } else { //do nothing } and so on 5 more times.... That seems horribly hackish/inefficient. Is there a better way? Code: [Select] if (isset($_POST['hidden']) && $_POST['hidden'] == "edit") { $cimage=trim(mysql_prep($_POST['cimage'])); $ctext=trim(mysql_prep($_POST['ctext'])); $cextra=trim(mysql_prep($_POST['cextra'])); $atext=trim(mysql_prep($_POST['atext'])); $aextra=trim(mysql_prep($_POST['aextra'])); $aimage=trim(mysql_prep($_POST['aimage'])); //update the answer edits $sql = "UPDATE cluesanswers SET ctext='$ctext', cextra='$cextra', cimage='$cimage', atext='$atext', aextra='$aextra', aimage='$aimage'"; $result = mysql_query($sql, $connection); if (!$result) { die("Database query failed: " . mysql_error()); } else { } Hi I am trying to select and order data/numbers from a colum in a mysql data base however i run the code and it returns no value just a blank page no errors or any thing so i think the code is working right but then it returns no result? Please help thanks Here is the code: <?php $host= "XXXXXX"; $mysql_user = "XXXXXX"; $mysql_password = "XXXXXX"; $mysql_database = "XXXXXXX"; $connection = mysql_connect("$host","$mysql_user","$mysql_password") or die ("Unable to connect to MySQL server."); mysql_select_db($mysql_database) or die ("Unable to select requested database."); $row = mysql_fetch_assoc( mysql_query( "SELECT XP FROM Game ORDER BY number DESC LIMIT 1" ) ); $number = mysql_result(mysql_query("SELECT XP FROM Game ORDER BY number DESC LIMIT 1"), 0); echo "The the highest XP is $number"; ?> hi guys, im new to this forum I'm new also to php, I need help from you guys: I want to display personal information from a certain person (the data is on the mysql database) using his name as a link: example: (index.php) names 1. Bill Gates 2. Mr. nice Guy i want to click Bill Gates (output.php) Name: Bill Gates Country:xxxx Age: xx etc. How can i make this or how to learn this? Hello im working on a project which involves marking attendance via an RFID tag and saving the time into an sql file. Everything seems to be working fine and the time stamp is successfully punched into the SQL but something is wrong with the php code thats supposed to display this data. Please if any one can take a look and help.
MY CODE for displaying the data (ViewAttendance.php): <?php include_once("header.php"); $attData = array(); $totDays = 0; if(isset($_REQUEST['submit'])){ $totDays = cal_days_in_month(CAL_GREGORIAN,$_REQUEST['month'],$_REQUEST['year']); $attData = $commonObj->getAttendanceData($_REQUEST['month'],$_REQUEST['year']); //print_r($attData); //print_r(date("d",strtotime($attData[0]['punch_time']))); } ?> <div class="container"> <div class="row"> <div class="col-sm-12"> <h4>Showing Attendance</h4> <form name="showAtt" method="post"> <div class="col-sm-4"><label>Select Month</label> <select name="month" class="form-control"> <?php for($i=1;$i<=12;$i++){?> <option value="<?php echo $i;?>"><?php echo $i;?></option> <?php }?> </select> </div> <div class="col-sm-4"><label>Select Year</label> <select name="year" class="form-control"> <?php for($i=date("Y");$i>=2010;$i--){?> <option value="<?php echo $i;?>"><?php echo $i;?></option> <?php }?> </select> </div> <div class="col-sm-4"> <p> </p> <input type="submit" value="Show" name="submit" class="btn btn-primary"> </div> </form> </div> </div> <div class="row"> <div class="col-sm-2"> <label class="btn btn-success btn-sm">Month:<?php echo @$_REQUEST['month'];?></label> </div> <div class="col-sm-2"><label class="btn btn-info btn-sm">Year: <?php echo @$_REQUEST['year'];?></label></div> </div> <div class="row"> <div class="col-sm-12" style="overflow: scroll;"> <?php if($totDays>0){?> <table class="table table-striped"> <tr> <th> Employee Name </th> <?php for($i=1;$i<=$totDays;$i++){?> <th> <?php echo $i;?> </th> <?php }?> <?php foreach($attData as $attk=>$attv){ $punchin = $commonObj->getTimeOfDate($attData[$attk]['punchin']); $punchout = $commonObj->getTimeOfDate($attData[$attk]['punchout']); ?> <tr> <th class="danger"> <?php echo $attv['name'];?> </th> <?php for($i=1;$i<=$totDays;$i++){?> <?php if($commonObj->getDayOfDate($attData[$attk]['punch_time']) == $i){ echo "<td class='success' id='att_$i'>".$punchin.'-'.$punchout;?> <table class="table table-responsive"style="display: none; position:relative;min-width:100px;max-width:200px; margin-top: -40px;" id="<?php echo "det_att_".$i;?>"> <tr> <td>Total hours:</td> <td><?php echo $commonObj->getHoursBetweenDates($attData[$attk]['punchin'],$attData[$attk]['punchout']);?> </td></tr> <tr> <td>UID:</td> <td><?php echo $attData[$attk]['rfid_uid'];?></td> </tr> </table> <?php }else {echo "<td class='info'>#na";}?> </td> <?php }?> </tr> <?php }?> </tr> </table> <?php }?> </div> </div> </div> </body> </html> <script> $(document).ready(function(){ $("td").hover( function () { var id = "#det_"+this.id; $(id).css({"display":"block"}); }, function () { var id = "#det_"+this.id; $(id).css({"display":"none"}); //console.log(id); //$(id).css("display","block"); }); }); </script> Display of (ViewAttendance.php):
MY SQL TABLE :
hello, i have a table in a database that stores information on powerpoint presentations like so: id, title, filename, presenter, program, session I want to query the data so that all entries are grouped by session (which is a date) and each presentation is displayed under its respective session in a table like so: [session] (i want to display each session once) [title] - [program] (then i want to display this information for each presentation in each session) [presenter] [session] [title] - [program] [presenter] etc... i am thinking of using group_concat for this but am not sure exactly how to pull it off. any help is greatly appreciated. thank you! I have page1.php which has a post form and page2.php which display data/results. I have a seperate php script file which queries a database. Having completed the query and assuming a result, I would end up with something like Code: [Select] while($result = mysql_fetch_assoc($query)) how do I get the data onto the display page. Looking at example approaches I found this using a go-between file Code: [Select] <?PHP include_once(process.php; process($_POST); display_results; ?> would display_results be a form of redirect? If not? Any help appreciated. Hi, I'm trying to joing two tables together, in the resulting PHP coding (See below) the issue I'm having the coding saying select the colour from the colour table where the model of car is the same as the model in the cars table. For example, if the car model is KA and in the table it is KA show the colours. I know this manual fix does the trick. [ $test = "KA"; $query_cols = "SELECT * FROM colours WHERE colours.model = '$test' "; ] But not the soultion any help would be much appericated thank you. [ include "connections/dbconnect.php"; $manfactures = "Ford"; $car_query = "SELECT * FROM cars WHERE make = '$manfactures'"; $car_result = mysql_query($car_query) or die ("Error in query: $car_query. ".mysql_error()); setlocale(LC_MONETARY, 'en_GB'); $fmt = '%i'; if (mysql_num_rows($car_result) > 0) { while ($car_row = @ mysql_fetch_array($car_result)) { $test = "KA"; $query_cols = "SELECT * FROM colours WHERE colours.model = cars.model"; $cols_result = mysql_query($query_cols) or die ("Error in query: $query_cols. ".mysql_error()); print " <table class='details'> <tr> <td rowspan='2'> <img src=\"". $car_row["image"] ."\" alt='" . $car_row["image_alt"] . "' /> </td> <td colspan='2'> <a href='" . $car_row["what_link"] . "'> " . $car_row["model"]." ".$car_row["model_details"] . " </a> </tr> <tr> <td> <p class='info'> RRP:<br/> What Price:<br/> Our Price:<br/> Savings of:<br/> Delivery Time: </p> </td> <td> <p class='info1'> "; echo money_format($fmt, $car_row["rrp"] ); print "<br/>"; echo money_format($fmt, $car_row["what_price"] ); print "<br/>"; echo money_format($fmt, $car_row["our_price"] ); $savings = $car_row["rrp"] - $car_row["our_price"]; print " <br/> <font color=\"red\">"; echo money_format($fmt, $savings ); print " </font><br/> " . $car_row["delivery_time"] . " </p> </td> </tr> <tr> <td> "; while ($cols_row = @ mysql_fetch_array($cols_result)) { ?> <a href='#' onmouseout='hideTooltip()' onmouseover='showTooltip(event,"<?php print "" . $cols_row["colour"] . ""; ?>");return false'> <?php print " <img src=\"". $cols_row["colour_img"] ."\" alt='" . $cols_row["colour_img_alt"] . "' /> "; } print " </td> </tr> "; } } else { echo "Aids!"; } print "</table>"; ?>] Hi all! I've been recently messing with PHP and MySQL to attempt to create a search function for my tables (too advanced, so I toned it down to learning to just display data from my table). Anyways, I'm watching a YouTube video on how to do it, and I'm copying his code exactly, but I'm still getting an error. Can anyone help? Thanks. Edit: Sorry, my error was snuggled down below the code. Anyways, my error is just my while echo appearing in and out of my tables on the page. My code: <?php //Make connection mysql_connect('localhost', 'root', 'test'); // select db mysql_select_db('testdatabase'); $sql="SELECT * FROM employees"; $records=mysql_query($sql); ?> <html> <head> <title>Employee Data</title> </head> <body> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>ID</th> <th>First name</th> <th>Surname</th> <th>Age</th> </tr> <?php while($employees=mysql_fetch_assoc($records)){ echo "<tr>"; echo "<td>".$Employee['ID']."</td>"; echo "<td>".$Employee['First name']."</td>"; echo "<td>".$Employee['Surname']."</td>"; echo "<td>".$Employee['Age']."</td>"; echo "</tr>"; } // end while ?> </table> </body> </html> Edited by thwikehu1990, 19 January 2015 - 01:33 PM. |