PHP - Echo Background Image Breaking Site
I am trying to add a background image via a custom style, but it breaks my site. I am a php novice, can someone point out my error please? The echo is being used other places on this page, so I know this code is ok: <?php echo $event->data->thumbnails['medium']; ?> but I am missing something here, this keeps breaking the page: <?php echo '<article data-style="'.$label_style.'" style="background-image:url(\<?php echo $event->data->thumbnails['medium']; ?>\")" class="mec-event-article mec-clear '.$this->get_event_classes($event).'"' . $colorful_bg_color . '>'; ?> Thanks for any help, as I learn! Similar TutorialsHow can i make echo "<b>Site:</b> ".$req_user_info['site']."<br>"; linkable The site raw fron the db contains an site url. Regards Hi Guys Hoping somebody can help me again please? I have some code which calls and displays all images in the file structure on my webpage. Code: [Select] <?php //to display image from source $dir = "profpics/"; //opening directory if ($opendir = opendir($dir)) { //reading directory while (($file = readdir($opendir)) !== FALSE) { if ($file!="."&&$file!="..") echo "<img src = '$dir/$file' img width='38' img height='38'><br>"; } } ?> This works fine, but what i want is for only the image that relates to the logged in user to be displayed. Both the user id and image id are stored in the same row of my database Sorry if this is confusing. Can anybody help? Thanks Hi, I have a search results page that return the results based on "Make" & "Model" of vehicle. The question is, can an image be echoed onto that results page based on which make and model has been searched for? The image is stored in a field called "Image_Van" so would need to display that depending on the row in that database that has been selected from Make & Model... Hope this makes sense! <?php //info bars colour $color_info="#D6D685"; // Almost Silver //FFFFCC $color1="#E9E9E9";// Light Blue $color2="#EAD5FF";// Light Blue //include function library code include_once("func_lib.php"); // use the user_connection include file's connectDB function include_once("usr_conn.php"); if (!connectDB()) { echo "<p>Unable To Connect To Database</p>"; return; } //test that make and model are passed in, if they are assign them if (($_GET ['make'] == "MAKE") or ($_GET ['model'] == "MODEL")) { $errMessage = "<br><br><b><font class=small>Your search hasn't returned any results, please re-enter your search again.</font></b><br><br><a href=van_accessories.php>Search again</a><br><br>"; } else { // get search values for make and model, removing " and ' chars $strMake = mysql_escape_string($_GET ['make']); $strModel = mysql_escape_string($_GET ['model']); } // set the Prod_Type that is to be shown regardless of car make and model $strDefaultProd = "XD"; //write query string that will pased in paging links $strQuery = "make=".$strMake."&model=".$strModel."&"; //echo $strQuery; //grab the page number that we're on $page = mysql_escape_string($_GET ['page']); //$strMake = "FIAT"; //$strModel = "Uno"; //create sql query $sqlSelect = "SELECT Prod_ID, Prod_Type, Prod_Model, Prod_Make, Prod_REF, Product_Desc, Price_ExVat, image_name, Image_Van FROM products"; //change this back to 'FILL THIS IS IN' to switch accessories off! $criteria = " WHERE (Car_Make = '".$strMake."' AND Car_Model = '".$strModel."' AND Default_Code = 'RS') OR (Car_Make = 'all' AND Default_Code = 'SA')"; //$criteria = " WHERE Car_Make = '".$strMake."' AND Car_Model = '".$strModel."'"; // assign the basic sqlquery $sqlquery = $sqlSelect . $criteria; //echo $sqlquery; #debug //get the result set $result = mysql_query($sqlquery); $count = mysql_num_rows($result); $full_count = $count; //set max number of records per page $records_per_page = 999; //Next figure out how many pages you'll have. $total_pages = ceil( $count / $records_per_page ); /* This just sets up a page variable which will be past in a "next" and "prev" link. The first link to this page may not actually have $page so this just sets it up. */ if ( $page == "" ) { $page = 1; } //echo "<br>page number".$page; #debug # this will set up the "First | Prev | " part of our navigation. if ( $page == 1 ) { # if we are on the first page then "First" and "Prev" # should not be links. $naviagation = "<font color=\"#666666\">First</font> | <font color=\"#666666\">Prev</font> | "; } else { # we are not on page one so "First" and "Prev" can # be links $prev_page = $page - 1; $navigation = "<a href=\"van_steps_results.php?".$strQuery."page=1\">First</a> | <a href=\"van_steps_results.php?".$strQuery."page=".$prev_page."\">Prev</a> | "; } # this part will set up the rest of our navigation "Next | Last" if ( $page == $total_pages ) { # we are on the last page so "Next" and "Last" # should not be links // $navigation .= "<font color=\"#666666\">Next</font> | <font color=\"#666666\">Last</font>"; } else { # we are not on the last page so "Next" and "Last" # can be links $next_page = $page + 1; $navigation .= "<a href=\"van_steps_results.php?".$strQuery."page=".$next_page."\">Next</a> | <a href=\"van_steps_results.php?".$strQuery."page=".$total_pages."\">Last</a>"; } /* The final thing to do is your actual query, but first we have to figure out what the offset will be. */ $offset = ( $page - 1 ) * $records_per_page; //echo "<br>offset".$offset; #debug //create sql query $sqlSelect = "SELECT Car_Make, Car_Model, Prod_ID, Prod_Type, Prod_Model, Prod_Make, Priority, Prod_Code, Prod_REF, Product_Desc, Price_ExVat, Link, image_name, Image_Van FROM products"; $criteria = " WHERE (Car_Make = '".$strMake."' AND Car_Model = '".$strModel."' AND Default_Code = 'RS') OR (Car_Make = 'all' AND Car_Model = 'all' AND Default_Code = 'SA')"; $limit = " ORDER BY Priority ASC, Prod_Code ASC, Prod_ID ASC LIMIT $offset, $records_per_page"; // assign the basic sqlquery $sqlquery = $sqlSelect . $criteria . $limit ; //echo $sqlquery; //get the result set $result = mysql_query($sqlquery); // if no matches found from query if (!$result || (mysql_num_rows($result) == 0)){ //echo ("<b><font class=small>No matches were found.</font></b>"); } // display the results else{ // use rowcount to display total results found $count = mysql_num_rows($result); //echo $count; //echo("<p>Total Matches Found = " . $rowCount . "</p>"); //*debug } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Results Page:</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <!--script src="js/jquery.lint.js" type="text/javascript" charset="utf-8"></script--> <link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" /> <script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script> <!-- start header graphic html --> <style type="text/css"> <!-- .table { border: 0px none; border-collapse: separate; } BODY { } A { COLOR: #003366; TEXT-DECORATION: none; } A:hover { TEXT-DECORATION: underline; color: #900; } .small { FONT-SIZE: 8pt; FONT-FAMILY: Verdana; } .std { FONT-SIZE: 8pt; FONT-FAMILY: Verdana; COLOR: #000000; } .header { FONT-SIZE: 8pt; FONT-FAMILY: Verdana; FONT-WEIGHT: BOLD; COLOR:#000000; } .bigheader { FONT-SIZE: 8pt; FONT-FAMILY: Verdana; FONT-WEIGHT: BOLD; COLOR:#FFFFFF; } .error { FONT-SIZE: 8pt; FONT-FAMILY: Verdana; COLOR:#FF0000 } .headertable { FONT-SIZE: 8pt; FONT-FAMILY: Verdana; FONT-WEIGHT: regular; COLOR:#FFFFFF; BACKGROUND-COLOR:#000066; } .stdtable { FONT-SIZE: 8pt; FONT-FAMILY: Verdana; FONT-WEIGHT: regular; COLOR:#000066; } .style16 {font-size: 11px} .style7 { color: #CC0000; font-style: italic; } .small1 { FONT-SIZE: 8pt; FONT-FAMILY: Verdana; } .header1 { FONT-SIZE: 8pt; FONT-FAMILY: Verdana; FONT-WEIGHT: BOLD; COLOR:#000000; } a:link { color: #900; } --> </style> <div align="center"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td background=""><table width="100%" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td bgcolor="#003366"> </td> </tr> </table> <!--END header--> <table width="960" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td><div align="center"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="arial11"><table width="100%" border="0" cellpadding="10" cellspacing="0"> <tr> <td width="33%"><p><img src="2003/results.gif" alt="" width="238" height="43" /></p> <p> </p> <p> </p></td> </tr> </table></td> </tr> </table> </div></td> </tr> </table> <table width="950" border="0" align="center" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF"> <tr align="center" valign="top" class="std"> <td colspan="7"><hr width="500" size="1" /> <?php if (isset($errMessage)){ echo $errMessage; } // if no matches found from query if (!$result || (mysql_num_rows($result) == 0)) echo ("<b><font class=small>No matches were found.</font></b><br><br>"); // display the results else{ // use rowcount to display total results found echo("<br><p><em><font class=vehicle>Search Results for " . $strMake . " " . $strModel .".</em> Total Matches Found = " . $full_count . "</p>"); //*debug echo $navigation; } /* With your navigation built you can just echo that out any where you want it to appear. */ //echo $navigation; ?></td> </tr> <?php $title = "<tr align=\"center\" class=\"headertable\" height=\"32\">"; $title .= "<td width=\"95\"><img src=\"images/transparent.gif\" width=\"95\" height=\"1\" /></td>"; $title .= "<td width=\"60\">Make</td>"; $title .= "<td width=\"60\">Ref No.</td>"; $title .= "<td width=\"550\">Title/Description</td>"; $title .= "<td width=\"73\">Price Ex VAT</td>"; $title .= "<td width=\"73\">Price Inc VAT</td>"; $title .= "<td width=\"60\"><img src=\"2003/basket.gif\" width=\"21\" height=\"14\"></td>"; $title .= "</tr>"; //set the counters for the records results display screen $cnt = 0; $headercount1 = 0; $headercount2 = 0; $headercount3 = 0; $headercount4 = 0; $headercount5 = 0; $headercount6 = 0; $headercount7 = 0; while ($row = mysql_fetch_assoc($result)) { //cut the prod_type variable //get the length of the variable $strLength = strlen ($row["Prod_Type"]); //assign first 2 characters of variable $strPrefix = substr($row["Prod_Type"], 0, 2); //debug //echo "\n prefix :" . $strPrefix; //assign remaining characters of variable $strSuffix = substr($row["Prod_Type"], 2, $strLength); //debug //echo "\n suffix :" . $strSuffix; //set product header image depending on the Prod_Type Code //start the table row echo "<tr align=center><td colspan=7 class=small>"; //set bg cell color diff for BH make switch ($strPrefix) { case "BH": $color=$color2; break; default: $color=$color1; break; }//end switch switch ($strPrefix) { case "BH": if ($headercount1 == 0) { echo "<img border=0 src=2003/searchheaders/step.jpg></td></tr>"; echo $title; } $headercount1 ++; //$headercount1 break; // REMOVE ALL THIS COMMENTING IF NEEDED TO SHOW THE ROOF BARS! case "RB": // if ($headercount2 == 0) // { // echo "<img border=0 src=2003/searchheaders/NOTUSED.jpg alt=Roof-Bars></td></tr>"; // echo $title; // } // $headercount2 ++; //$headercount1 break; case "BX": if ($headercount3 == 0) { echo "<img border=0 src=2003/searchheaders/bulkheads.jpg alt=Roof-Boxes></td></tr>"; echo $title; } $headercount3 ++; //$headercount1 break; case "BR": if ($headercount4 == 0) { echo "<img border=0 src=2003/searchheaders/bulkheads.jpg alt=Bike-Racks></td></tr>"; echo $title; } $headercount4 ++; //$headercount1 break; case "SR": if ($headercount5 == 0) { echo "<img border=0 src=2003/searchheaders/bulkheads.jpg alt=Ski-Rack></td></tr>"; echo $title; } $headercount5 ++; //$headercount1 break; case "CR": if ($headercount6 == 0) { echo "<img border=0 src=2003/searchheaders/bulkheads.jpg alt=Canoe-Rack></td></tr>"; echo $title; } $headercount6 ++; //$headercount1 break; case "XD": if ($headercount7 == 0) { echo "<img border=0 src=2003/searchheaders/towbar.jpg alt=General-Accessories></td></tr>"; echo $title; } $headercount7 ++; } //end header image selection and close the table row. //echo "</td></tr>"; // if (($cnt++)%2) // { // $color="#E9E9E9"; // Almost Silver // } // else // { // $color="#E9E9E9";// Light Blue // } //print a product row if the prodtype isn't set to INFO $pop_link = ""; if ($strSuffix != "INFO"){ //test to see if an image exists for the product if ($row["Link"] <> NULL){ $pop_link = " <a href=\"products/".$row["Link"]."?iframe=true&width=650&height=500\" rel=\"prettyPhoto\" >More information >>>></a>"; } echo "<tr class=stdtable align=center height=25>"; //DISPLAY THUMB IMAGE IF ONE WAS LISTED IN THE image_name FIELD $p_Image_Van = htmlspecialchars($row["Image_Van"]); //echo "p_Image_Van:$p_image_name"; if ($p_Image_Van != "") echo "<td bgcolor=$color width=\"95\"><img src=\"images/product_images/$p_Image_Van\" border=\"0\" /></td>"; else echo "<td bgcolor=$color width=\"95\"><img src=\"images/transparent.gif\" width=\"95\" height=\"50\" border=\"0\" /></td>"; echo "<td bgcolor=$color width=\"60\">". htmlspecialchars($row["Prod_Make"]) . "</td><td bgcolor=$color width=\"60\">" . htmlspecialchars($row["Prod_REF"]) . "</td><td bgcolor=$color align=left class=\"infolink\" width=\"550\">" . htmlspecialchars($row["Product_Desc"]) . $pop_link . "</td><td bgcolor=$color width=\"73\">£" . number_format(htmlspecialchars($row['Price_ExVat']), 2) . "</td><td bgcolor=$color width=\"73\">£" . number_format((calcVAT (htmlspecialchars($row['Price_ExVat']))), 2) . "</td><td bgcolor=$color width=\"60\"><a href=basket.php?src=".urlencode($_SERVER['REQUEST_URI'])."&productID=" . $row["Prod_ID"] . "><img src=2003/buy.gif border=0></a></td></tr>"; } // if the prod type is set to INFO then print out a new row for that information else { echo "<tr class=stdtable align=center height=25 ><td colspan=7 bgcolor=$color_info><em><strong>" . htmlspecialchars($row["Product_Desc"]) . "</strong></em></td></tr>"; } } //****************************************************************************************************** /* //get all porducts from the database that are marked with prod_type XD regardless of car make and model $sqlSelectDefault = "SELECT Prod_ID, Prod_Type, Prod_Model, Prod_Make, Priority, Prod_Code, Prod_REF, Product_Desc, Price_ExVat FROM products"; $criteriaDefault = " WHERE Prod_Type LIKE '".$strDefaultProd."%'"; $limitDefault = "ORDER BY Priority ASC, Prod_Code ASC"; // assign the basic sqlquery $sqlqueryDefault = $sqlSelectDefault . $criteriaDefault . $limitDefault ; //echo $sqlquery; //get the result set $resultDefault = mysql_query($sqlqueryDefault); // if no matches found from query if (!$resultDefault || (mysql_num_rows($resultDefault) == 0)){ //echo ("<b><font class=small>No matches were found.</font></b>"); } // display the results else{ // use rowcount to display total results found $countDefault = mysql_num_rows($resultDefault); //echo $count; //echo("<p>Total Matches Found = " . $rowCount . "</p>"); //*debug } //set product header image depending on the Prod_Type Code //start the table row echo "<tr align=left><td colspan=6 class=small>"; echo "<img border=0 src=2003/searchheaders/general.jpg alt=General-Accessories>"; echo "</td></tr>"; while ($rowDefault = mysql_fetch_assoc($resultDefault)) { //cut the prod_type variable //get the length of the variable $strLengthDefault = strlen ($rowDefault["Prod_Type"]); //assign first 2 characters of variable $strPrefixDefault = substr($rowDefault["Prod_Type"], 0, 2); //debug //echo htmlspecialchars($rowDefault["Prod_ID"]); //echo "\n prefix :" . $strPrefixDefault; //assign remaining characters of variable $strSuffixDefault = substr($rowDefault["Prod_Type"], 2, $strLengthDefault); //debug //echo "\n suffix :" . $strSuffixDefault; if ($strSuffixDefault != "INFO"){ $color="#E9E9E9"; // Almost Silver //print a product row if the prodtype isn't set to INFO echo "<tr class=stdtable align=center height=25 ><td bgcolor=$color>". htmlspecialchars($rowDefault["Prod_Make"]) . "</td><td bgcolor=$color>" . htmlspecialchars($rowDefault["Prod_REF"]) . "</td><td bgcolor=$color align=left>" . htmlspecialchars($rowDefault["Product_Desc"]) . "</td><td bgcolor=$color>?" . number_format(htmlspecialchars($rowDefault['Price_ExVat']), 2) . "</td><td bgcolor=$color>?" . number_format((calcVAT (htmlspecialchars($rowDefault['Price_ExVat']))), 2) . "</td><td bgcolor=$color><a href=basket.php?src=".urlencode($_SERVER['REQUEST_URI'])."&productID=" . $rowDefault["Prod_ID"] . "><img src=2003/buy.gif border=0></a></td></tr>"; } // if the prod type is set to INFO then print out a new row for that information else { echo "<tr class=stdtable align=center height=25 ><td colspan=6 bgcolor=$color><em>" . htmlspecialchars($rowDefault["Product_Desc"]) . "</em></td></tr>"; } } */ ?> <tr align="center"> <td colspan="7" class="small1"></td> </tr> <tr> <!-- <tr align="center" class="headertable" height="32"> <td width="145">Product Name</td> <td width="178">Ref No.</td> <td width="280">Description</td> <td width="73">Price Ex VAT</td> <td width="73">Price Inc VAT</td> <td width="60"><img src="2003/basket.gif" width="21" height="14"> </td> </tr>--> <td colspan="7" height="1" bgcolor="#003366"><img src="colour_spacer.gif" width="756" height="1" /></td> </tr> </table></td> </tr> </table> <p><br /> </p> </p> <div align="center"><br /> </div> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> </td> </tr> </table> <?php //free up some memory mysql_free_result($result); // close the aatabase connection mysql_close(); //include footer code ?> <br /> </table> </html> Hi guys, Probably going to be a very basic question but i'm lost, i'm trying to figure out how to display an image if the value returned is equal to or greater than a certain number, more of a hypothetical question at the moment, Thanks in advance This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348171.0 I'm having a really hard time getting my carousel to display in a line when I call my images from the table:
<div id="user-gallery"> <h2>Recent Images</h2> <button class="prev"><<</button> <button class="next">>></button> <?php include("file/image/upload_file.php"); $select_query = "SELECT `images_path` FROM `images_tbl` ORDER by `images_id` DESC LIMIT 9"; $sql = mysql_query($select_query) or die(mysql_error()); while($row = mysql_fetch_array($sql,MYSQL_BOTH)){ ?> <div class="anyClass"> <ul> <li><img src="<?php echo $row["images_path"]; ?>" alt="" width="125" height="70" ></li> <li><img src="<?php echo $row["images_path"]; ?>" alt="" width="125" height="70" ></li> <li><img src="<?php echo $row["images_path"]; ?>" alt="" width="125" height="70" ></li> <li><img src="<?php echo $row["images_path"]; ?>" alt="" width="125" height="70"></li> </ul> </div> <?php } ?> </div>Without the carousel it will display perfectly, but as soon as I implement it, the images won't behave normal :/ hey guys i have this echo (empty($info['ID_Etudiant'])? "No image": "<img src=Etudiants/".$info['photo'] ." border=0 width=100>"); the echo pic if thee is one in database works.but if there is no pic in database it shows nothing? OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=332275.0 i cant find any working stuff on this i cant just start learning as3 and flash development for a small feature :\ i found this two guides: http://www.marchawkins.com/2010/03/17/capture-and-upload-a-webcam-still-with-flash/ dont work for me do error couldnt make it work :| http://www.endseven.net/?p=9# didnt work for me to... im beggin you guys i really need this script just a simple snap from webcam and it upload to the site thats it. Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> after spending many hours thinking this through and not really getting anywhere, trying to figure out how this site works, so that i can replicate it and make a single image from multiple images that are positioned overlaying with css positioning
the site in question is: http://www.dahippo.c...6360ZZ0ZZ0ZZ0ZZ
it is a type of calculator for an online game, the part that interests me is the image of the ship that is built up from many images
is also uses a php script to place all these images into on image file outputted to html, this is what interests me and i am trying to recreate, like he http://www.dahippo.c...6360ZZ0ZZ0ZZ0ZZ
here is the outputted html:
<html> <head> <meta name="viewport" content="width=device-width, minimum-scale=0.1"> <title>get.php (635x317)</title> </head> <body style="margin: 0px;"> <img style="-webkit-user-select: none; cursor: -webkit-zoom-in;" src="http://www.dahippo.com/bp/ship/get.php?image=4J01Q180O0K0E013C3A3C3A3636360ZZ0ZZ0ZZ0ZZ" width="408" height="204"> </body> </html>what php code used in the get.php script make all these images with css positioning into 1 image? i have asked the site owner, and got no reply :/ I have a page that displays various articles. I would like to show a background image for each article. Let's say I have articles for beaches. I would like to have a beach photo. Airplane article, show airplanes, etc. How can I accomplish this. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=319094.0 This creates an image 1500x1500 pixels. But it creates it in black... how can i make it white. And i have to use imagecreatetruecolor() not imagecreate(). <?php $im = imagecreatetruecolor(1500,1500); // Output the image to the browser header('Content-type: image/jpg'); imagejpeg($im); imagedestroy($im); ?> Thanks! I have a site that everything was typed manually, but I want to get all this info off so I can put all info into a database for easier editing and so forth.
I'm trying this code, which works to a point.
function curl($Url){ if (!function_exists('curl_init')){ die('cURL is not installed. Install and try again.'); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); $start = strpos($output, '<h2 style="text-align: center;"><span style="text-decoration: underline;">Alabama Tattoo Shops</span></h2>'); $end = strpos($output, '<p>', $start); $length = $end-$start; $site = substr($output, $start, $length); $site = explode("<p>", $site); foreach ($site AS $line) { print_r($line); } return $output; } $site = curl('http://www.tattooshopusa.com/alabama/'); I'm experimenting with a basic CRUD App. The table created by the code below renders, however when I view source, the last tag is the closing </tr> after the while loop finishes. There's nothing after that. No closing table, html, or body tags. I can't see what I've done wrong.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Eric's PHP CRUD App</title> <style type="text/css"> table { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; text-align: center; margin: 0 auto; } table td { text-align:center; border: 1px solid #dfdfdf; } tr:nth-child(odd) { background: #fdfdfd; } tr:nth-child(even) { background: #B8D3FF; } th { background-color:#ccc; } .center { width: 1050px; margin:0px auto; } h1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; padding-bottom: 15px; text-align: center; margin: 0 auto; color: white; } </style> </head> <body bgcolor="#999"> <?php require_once("db_connect.php"); echo "<h1>Update Student Records</h1>"; echo "<table cellpadding='10'>"; echo "<tr bgcolor='#cccccc'>"; echo "<th>First Name</th>"; echo "<th>Last Name</th>"; echo "<th>Test 1 Grade</th>"; echo "<th>Test 2 Grade</th>"; echo "<th>Test 3 Grade</th>"; echo "<th>Test 4 Grade</th>"; echo "<th>Final Exam Grade</th>"; echo "<th>Average Grade</th>"; echo "<th>Final Grade</th>"; echo "<th>delete</th>"; echo "<th>edit</th>"; echo "</tr>"; $sql = "SELECT * FROM students"; $result = mysqli_query($link, $sql) or die(mysql_error()); while($row = mysqli_fetch_array($result, MYSQLI_ASSOC) or die(mysql_error())) { $final = ""; $average = (($row["test1Grade"]) + ($row["test2Grade"]) + ($row["test3Grade"]) + ($row["test4Grade"]) + ($row["finalExamGrade"])) / 5; if ($average >= 90) { $final = "A"; } else if ($average >= 80) { $final = "B"; } else if ($average >= 70) { $final = "C"; } else if ($average >= 60) { $final = "D"; } else if ($average < 60) { $final = "F"; } echo "<tr>"; echo "<td>" . $row["firstName"] . "</td>"; echo "<td>" . $row["lastName"] . "</td>"; echo "<td>" . $row["test1Grade"] . "</td>"; echo "<td>" . $row["test2Grade"] . "</td>"; echo "<td>" . $row["test3Grade"] . "</td>"; echo "<td>" . $row["test4Grade"] . "</td>"; echo "<td>" . $row["finalExamGrade"] . "</td>"; echo "<td>" . round($average) . "</td>"; echo "<td>" . $final . "</td>"; echo "<td><a href='delete.php?id=" . $row['studentID'] . "'>›</a></td>"; echo "<td><a href='update.php?id=" . $row['studentID'] . "'>›</a></td>"; echo "</tr>"; } echo "</table>"; ?> <a href='insert.php'>Add new student</a> </body> </html> Edited by Ch0cu3r, 13 November 2014 - 01:07 PM. Added code tags What is the best way to break up repeating code? Make each page from a standard template (e.g. Header, Columns, Footer) and include the variable content using PHP?? Or make each page a stripped down PHP page which creates the variable content and then Includes the static parts (e.g. Header, Columns, Footer)?? Hope you follow me?! :-/ Debbie I am trying to break down the tables i have on my website in order to place them into my mySQL database. I am new to php and have been having some trouble and any help would be greatly appreciated. So far I have this but it doesnt seem to be working. I am using DOMDocument but I wonder if maybe preg_match woulf be better? Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\Hosting\5915198\html\2.php on line 11 <?php // Load html string $dom = new DOMDocument(); $dom->loadHTML('www.empirebuildingsestate.com/company.html'); // Get tables from html $tables = $dom->getElementsByTagName('tr'); // Get rows from tables $rows = $tables->item(0)->getElementsByTagName('td'); // Loop over each row foreach ($rows as $row) { // Get each column by tag name $cols = $row->getElementsByTagName('td'); // Echo values (here you can assign them in array for example) echo $cols->item(0)->nodeValue.'<br />'; echo '<hr />'; } ?> |