PHP - Data Entry Grid
Need help in achieving a data entry grid.
I have two tables am_user (idam_user, name) and am_activity (idam_act, act) with the data Data for am_user is 1, John 2, Mary 3, Kate Data for am_activity is 1, Cooking 2, Cleaning 3, Painting I have a third table that stores the role played by each user for the activities. am_role (idam_role, role) 1, Manage 2, Observe 3, Documents I want my User table to be my header, Activity table to my 1st column and Role table to populate the data grid John Mary Kate Cooking Manage Document Observe Cleaning Document null Manage Painting Observe Document Manage By putting two while loops I am able to generate the header and 1st column but I need help in populating the grid in between. Also I want my data entry area (rows and column besides header and 1st column) to have lookup where they can select values from the am_role table. So, John can "Manage" "Painting" tomorrow if he wants to The two while loops are Code: [Select] $query = "select idam_user, Name "; $query .= " from am_user "; $result = mysql_query($query) or die(mysql_error()); // display data in table echo "<center>"; echo "<table>"; echo "<tr>"; echo "<th></th>"; // loop through results of database query, displaying them in the table while($row = mysql_fetch_array( $result )) { // echo out the contents of each row into a table echo '<th>' . $row['name'] . ' '; echo "</th>"; } echo "</tr>"; $query = "select idam_act, act "; $query .= " from am_activity "; $result = mysql_query($query) or die(mysql_error()); // display data in table // loop through results of database query, displaying them in the table while($row = mysql_fetch_array( $result )) { // echo out the contents of each row into a table echo '<tr>'; echo '<td>' . $row['act'] . '</td>'; echo '</tr>'; } // close table> echo "</table>"; echo "</center>"; Please advise if this thought is realistic and how can I achieve it. Thanks in anticipation. Similar TutorialsHello all: Let me give you some background, over the past 10 years I have dealt with many forums, and even built some limited PHP scripts myself for various things related to those forums. Usually modifications to expand the forums abilities. So I had thought I had a fairly good handle on PHP in general... LOL, that is until recently when I decided to take on a slightly different/larger challenge. Recently one of my forum users requested the creation of a X,Y Coordinate grid, where they could put into it certain bits of information and it would return showing them the X,Y location of thier various work attached in some way shape or form to his site. I had thought this would be a simple project, as I have worked with GD image creation before, as well as SQL statements many times, it simply should have been a blending of my exsisting knowledge into one program. While this was a unique challenge for me, its one I seem to have been unable to plug. I have searched the web extensively the last 2 weeks hoping to find a tutorial, and sadly while I can find a great many related to bar graphs and line graphs, I can't seem to find a single one related to a simple X Y coordinate graph, yet I know I have seen them done many times. I am at a total loss on this one and so far my attempts have garnered me 0 results. I can't even create a 20 x 20 grid with any success... LOL. I am hoping one of you would be kind enough to post a tutorial, with a simple code that would produce a grid using GD, or even some other form of image generation, with 1 - X Y plot in it generated either from SQL or from the program its self, so that I could see a working version and with luck go from there to expand it to my needs. Thank you. 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! Hey folks! I am looking to build a small adventure game in PHP and the key to this will be a 3x3 (or possibly bigger) grids of squares, with the user situated in the centre. I therefore need to be able to figure out the co-ords of the surrounding squares. Presumably I will need to define the size of the master grid, then using the co-ords of the current square (defined from a database containing the users location), calculate the co-ords for the surrounding 8 grid squares. Has anyone had any experience with this? Where should I start? (Maths isn't my strong point tbh, but I can pick things up quickly) Thanks in advance! EDIT - in case it wasn't too clear, the "world map" would be something like 1000x1000 squares, but the player can only see the 3x3 grid at there location. Dear All, I am developing a website www.computationalphotography.in on which I need to register new users. I have designed an HTML form for this purpose, but will need help with writing the code for checking and validating the data in the respective fields. The code for my web form is below and the address of the website is www.computationalphotography.in/registration.php: Code: [Select] <html> <head> <title> Photography Experiment Registration </title> </head> <body> <h1> Questionnaire </h1> <h3> We would like to know about your background and interests in photography. For each multiple-choice question, please circle all answers that apply.</h3> <form method="post" action="registration.php"> Name <input name="name" type="text"> <br> <br> <input name="email" type="text"> <br> <br> 1.) Roughly How many pictures do you take each year? <br> <br> <input name="radios" type="radio" value="a"> a) a few: <10 in a year <br> <input name="radios" type="radio" value="b"> b) many: probably 100's a photos a year <br> <input name="radios" type="radio" value="c"> c) a lot: probably 1000's of photos a year <br> <br> 2.) Do you share your pictures with anyone? <br> <input name="radios" type="radio" value="a"> a) No <br> <input name="radios" type="radio" value="b"> b) Yes, but only with friends or family <br> <input name="radios" type="radio" value="c"> c) Yes, I share with friends or family and also post on public sites such as Flickr, Picasaweb, or Snapfish for anyone to see. <br> <input name="radios" type="radio" value="d"> d) Yes, I share frequently and I have also published my photos in books or magazines, or exhibitde my photos in shows. <br> <br> 3.) How much training in photography have you had? <br> <input name="radios" type="radio" value="a"> a) None <br> <input name="radios" type="radio" value="b"> b) Some, but it's self-taught from books or websites <br> <input name="radios" type="radio" value="c"> c) Quite a bit: I have taken courses in photography <br> <input name="radios" type="radio" value="d"> d) A lot:I have completed a degreee or certificate in the subject <br> <br> 4.) How do you describe yourself as a photographer? <br> <input name="radios" type="radio" value="a"> a) A novice:someone who takes a few pictures occasionally <br> <input name="radios" type="radio" value="b"> b) An amateur:someone who takes many photos, but doesn't usually share them <br> <input name="radios" type="radio" value="c"> c) An enthusiast:someone who loves to take pictures, possibly shows them with oters on public sites, or who might own a DSLR, or frequently uses a camera in other than "automatic mode" <br> <input name="radios" type="radio" value="d"> d) An expert:skilled photographer who has published their work, or exhibited their work in shows, or has been paid for their work <br> <br> 5.) Do you have artistic training or exposure? <br> <input name="radios" type="radio" value="a"> a) No <br> <input name="radios" type="radio" value="b"> b) I visit museums or art galleries <br> c) I have studied art: please describe <br> <textarea name="data5c" cols="50" rows="5"> </textarea> <br> d) I am a practicing artist: please describe <br> <textarea name="data5d" cols="50" rows="5"> </textarea> <br> <br> 6.) Some optional information, if you don't mind. We respect your privacy. <br> <br> Age <br> <textarea name="6a" cols="1" rows="1"> </textarea> <br> <br> Gender <br> <input name="radios" type="radio" value="a"> a) Male <br> <input name="radios" type="radio" value="b"> b) Female <br> <br> Languages Spoken <br> <textarea name="6b" cols="25" rows="2"> </textarea> <br> <br> Languages Read <br> <textarea name="6c" cols="25" rows="2"> </textarea> <br> <br> <br> <input type="submit" value="Send"> <input type="reset" value"Reset"> </form> </body> </html> Kindly help me out with this issue. Thank you for your help in this regard. Can anyone point out what's wrong with my feedback.php? It used to work fine and I don't think I did anything but it stopped working - i.e. I had it on a site which I never looked at and when I did look at it I noticed the rubbish written to the database had inexplicably stopped being written there some months ago..... since then I've tried to clean it up and use it elsewhere ( I'm a baby at php and most else) but I can't get it to go right. In this attempt it was giving me the dreaded 'headers already written..' error and I (after googling) took out all the blank space I could and extra comments and what not and stuck in some debugging prints for me and now I get no errors but I get nothing written to the database and no email sent to me. If anyone cares to look at it to help me out, here it is, warts and all, with just the names changed to protect the innocent. <? // mail it $mailto = 'med@yahoo.com' ; $subject = "Ploverpark Feedback Form" ; $formurl = "feedback.html" ; $errorurl = "error.html" ; $thankyouurl = "thankyou.html" ; $uself = 0; $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $username = $_POST['username'] ; $firstname = $_POST['firstname'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $secondname = $_POST['secondname'] ; $country = $_POST['country'] ; $phone = $_POST['phone'] ; // do write to database now--------------------------- $link = mysql_connect("mydb.com", "my_pkguest", "password") or die("Could not connect : " . mysql_error()); print "Connected successfully<p>"; $DB = "my_pkguest"; $table = "clients"; mysql_select_db($DB) or die ("Database $DB not select.." . mysql_error()); print "Successfully select the Database: $DB "; $query = "INSERT INTO $table(username,firstname,secondname,email,country,phone,comments) values('$username','$firstname','$secondname','$email','$country','$phone','$comments')"; print "Successfully inserted to table: $table "; //------------------------------------------------------ $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } print "Now past the if isset "; //if (empty($name) || empty($email) || empty($comments)) { // header( "Location: $errorurl" ); // exit ; //} if ( ereg( "[\r\n]", $username ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit ; } print "Now past the if ereg "; if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "UserName of sender: $username\n" . "Firstname of sender: $firstname\n" . "Secondname of sender : $secondname\n" . "Country of sender : $country\n" . "Phone number of sender: $phone\n" . "Email of sender: $email\n" . "------------------------- COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n" ; print "Now past the messageproper "; mail($mailto, $subject, $messageproper, "From: \"$username\" <$email>" . $headersep . "Reply-To: \"$username\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" ); print "Now past the mail"; //header( "Location: $thankyouurl" ); // exit ; ?> Hello all. I am finishing up a paypal IPN php script and was wondering how I can take some data and cut some of it off before I enter it into the mysql database? Heres what I have. $payment_date = HH:MM:SS DD Mmm YY, YYYY PST This comes from paypal. I want to in my code take that and automatically cut off the HH:MM:SS part. So my question is, how can I take a known piece of data and automatically trim the first 9 spots off of it? Something like: $payment_date = HH:MM:SS DD Mmm YY, YYYY PST Minus 1 thru 9 of $payment_date = $result $payment_date2 = $result Any help? Thanks! Newbie here, I am actually a math teacher working on creating a simulated store front for my students where they keep up with inventory, budgeting etc. Everyday my students will have to look at how much product is in stock, how much product was sold, and then input how much should be ordered for the next day. I am working on an answer key that will be used to validate students input but the 'quantity' and 'sold' fields will be relative to the most recent post. Right now the code below pulls all the rows under 'quantity', but I need it to only pull the most recent post. I have done my best to search the forum and try to find how to do this, but admittedly I am not even really sure what to be searching for. Any help would be great. Code: [Select] <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("myDatabase", $con); $result = mysql_query("SELECT * FROM myTable"); while($row = mysql_fetch_array($result)) { $quantity = $row['quantity']; $sold = $row['numbersold']; $needed = $row['remaining']; echo $needed-($quantity-$sold); } mysql_close($con); ?> Hello,
I've tried to get a dynamic table from an external page, and searching for entries in it, so i used a dynamic XLS file using php excel reader. I only exported the file, but i couldn't search for data.
Can i get some help please ?
I'm trying to have a running total of the number of views an image gets. My test file works perfectly every time. The actual file, image_win.php, does not and after much testing can't see what's wrong. This files STRANGENESS: the first two views count fine, with 1 added the total in the field image_visit. But every time after that 2 is added to the total in image_visit. Very bizarre. Thanks for taking a look -Allen Code: [Select] <?php ////////TEST IMAGE_WIN //////////THIS WORKS include_once "scripts/connect_to_mysql.php"; include_once "scripts/paths.php"; $art_id = 372; $QUERY="SELECT user_id FROM artWork WHERE art_id = '$art_id'"; $res = mysql_query($QUERY); $num = mysql_num_rows($res); if($num >0){ while($row = mysql_fetch_array($res)){ $owner_id = $row['user_id']; } } mysql_query("UPDATE userInfo SET image_visit = image_visit +1 WHERE user_id = '$owner_id'"); ?> <?php //////// image_win.php /////////THIS DOES NOT WORK $user_id=$_SESSION['user_id']; include_once "scripts/connect_to_mysql.php"; include_once "scripts/paths.php"; $image_link = $_GET['image_link']; $art_id = $_GET['art_id']; ?> <!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" /> <meta name="viewport" content="width=device-width, height=device-height, target-densityDpi=device-dpi"> <title>Image Window</title> </head> <body bgcolor="#000000" leftmargin="0"> <div align="center" > <img src="slir/w640-h535/<?php echo $path.$image_link.$postCat; ?>" /> <?php $QUERY="SELECT user_id FROM artWork WHERE art_id = '$art_id'"; $res = mysql_query($QUERY); $num = mysql_num_rows($res); if($num >0){ while($row = mysql_fetch_array($res)){ $owner_id = $row['user_id']; } } mysql_query("UPDATE userInfo SET image_visit = (image_visit +1) WHERE user_id = '$owner_id' "); ?> MOD EDIT: code tags added. Alright, wasn't quite sure how to summarize this in the title, but I want to: Check if a user status is "active" or not based on the UserName input. I have a table witch holds: Code: [Select] VarChar Username Var CharPassWord int Active Ted TedsPW 1 something like the above(assuming it formatted correctly. In my php script I will want to input a variable for Username to check for: inputUN in this example would be "Ted". $UserNameToCheck = $_GET['inputUN']; Then I want to check for that UserName in the database, if it exists, I want pull the value for the "Active" field for just that UserName and echo it. Thanks for any help. I am using php to upload a file to my server, and at the same time inserting the files name and url into my mysql database.
$sql = "UPDATE uploads SET name = '$name', url='$target_path'"; $statement = $dbh->prepare($sql); $statement->execute();This is working, however, when I upload a new file, rather than making a new entry in my database, it just overwrites the first one. I'm quite new at mysql so was wondering how I would make it add new entrys instead of overwriting the current one? Hi, I'm not too sure how to word this, but what I want to is to have a timetable for the 7 days of the week and 24 hours of the day, which gives 100-200 possible combinations. A user will select a checkbox and click submit which will then upload to a mysql database with the respective information. My question is, is there a way that the check box will dynamically select the day and time based on the row and column in it, as opposed to having 168 different names and values for each checkbox? I hope I have made my point succinctly but please post back if any more info is needed. Ta. How do I create a coordinate map in php? I created ordered pairs and I want to plot them on a grid. Grid is about 200000x200000. How i can create alphabetic grid . like on this website http://www.vietnamworks.com/jobseekers/search.php Trying to figure out my game map. Here is what's going on: Any player can view themself on the map and also the user at this location: x:50, y50. For some reason the map will not show anyone else. If you would like to see it, just go to http://www.gglegends.net/map.php and login with the credentials below (only 1 user can be logged in at a time): Credential for Demo Account - (I have restricted areas that affect others gameplay and areas that change the demo account) Username: demo Password: pass Other map locations to try out: x:60, y:60 x:19, y:79 x:98, y:72 x:75, y:51 x:97, y:26 x:66, y:12 Here is the complete code to my map: <?php require 'includes/header.php'; //Check to see if user exists in the map table, if not redirect location to get coordinates $user_map_check_results = $db->query ("SELECT * FROM map WHERE uID=".$user['uID'].""); $user_map_check = mysql_num_rows($user_map_check_results); if ($user_map_check == 0){ echo '<META HTTP-EQUIV="Refresh" Content="0; URL=firstrun.php">'; die(); } //Fetch the largest x coordinate in the map table. $map_size_x_result = $db->query( "SELECT MAX(x) AS map_max_x FROM map" ); $map_size_x = $db->fetch( $map_size_x_result ); //Fetch the largest y coordinate in the map table. $map_size_y_result = $db->query( "SELECT MAX(y) AS map_max_y FROM map" ); $map_size_y = $db->fetch( $map_size_y_result ); //Set map size. Determined by largest x and y coordinates. $grid_x = (int)$map_size_x['map_max_x']; $grid_y = (int)$map_size_y['map_max_y']; //x and y rows to display at a time. $display_rows = (int)10; //Fetch all user locations. $users_map_result = $db->query( "SELECT * FROM map LEFT JOIN users ON map.uID=users.uID" ); $users_map = $db->fetch( $users_map_result ); //Fetch user map location from database. $user_location_result = $db->query( "SELECT * FROM map LEFT JOIN users ON map.uID=users.uID WHERE map.uID=".$user['uID']."" ); $user_location = $db->fetch( $user_location_result ); //default display coordinate if none specified - will be user map location. $x = (int)$user_location['x']; $y = (int)$user_location['y']; $param_x = $_REQUEST["xcord"]; $param_y = $_REQUEST["ycord"]; if (isset($param_x) && isset($param_y)) { //validate that the parameter is a legit point. if (($param_x <= $grid_x) && ($param_x >= 1) && ($param_y <= $grid_y) &&($param_y >= 1)) { $x = (int)$param_x; $y = (int)$param_y; } } //set map location to the center of the map. $display_half = round($display_rows / 2); $other_half = $display_rows - $display_half; //display the target in the middle. $start_x = ($x - $display_half) +1; $end_x = $x + $other_half; //if the $start_x variable is less than 1 the grid would be in the negatives. so set it to 1. if ($start_x < 1) { $start_x = 1; $end_x = $display_rows; } else //if $end_x is off the grid we have to compensate and add the remaining rows to the start. if ($end_x > $grid_x) { $extra = $end_x - $grid_x; $end_x = $grid_x; $start_x = $start_x - $extra; } //same applies for the y axis. $start_y = ($y - $display_half) +1; $end_y = $y + $other_half; //if the $start_y variable is less than 1 the grid would be in the negatives. so set it to 1. if ($start_y < 1) { $start_y = 1; $end_y = $display_rows; } else //if $end_y is off the grid we have to compensate and add the remaining rows to the start. if ($end_y > $grid_y) { $extra = $end_y - $grid_y; $end_y = $grid_y; $start_y = $start_y - $extra; } ?> <b><tl>World Map</tl></b><br /> <img alt="" src="images/seperator.gif" /><br /> Click anywhere on the map to begin moving around. You can click on players name's to view their profile.<br /><br /> Move to Map Location or <a href="map.php"><u>Return to base</u></a>. <?php echo "Current Map Coordinates: X $x - Y $y"; ?><br /> <!-- Search custom coordinates --> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="GET"> <input name="xcord" type="text" size="3" maxlength="2" onblur="if ( this.value == '' ) this.value = this.defaultValue" onfocus="if ( this.value == this.defaultValue ) this.value = ''" value="x"> <input name="ycord" type="text" size="3" maxlength="2" onblur="if ( this.value == '' ) this.value = this.defaultValue" onfocus="if ( this.value == this.defaultValue ) this.value = ''" value="y"> <input type="submit" value="Submit"> </form> <br /><br /> <!-- Show map --> <table width="750" cellspacing="0" cellpadding="1" border="0"> <?php //these 2 for loops represent the y and x axis //using the data collected above the loops will properly display the grid. for ($Ty = $start_y; $Ty <= $end_y; $Ty++) { //start new row echo '<tr>'; for ($Tx = $start_x; $Tx <= $end_x; $Tx++) { //show grid DisplayGrid($Tx,$Ty); } echo '</tr>'; } ?> </table> <?php //Function to disaply the map. function DisplayGrid($grid_x,$grid_y) { global $x, $y, $user_location, $users_map; $bgimg = 'grass.gif'; $building = ''; if ($grid_x == $user_location['x'] && $grid_y == $user_location['y']) { $building = '<img src="images/map/building.gif" alt="" border="0" /><br />'; $user_map_name = '<br /><a href="player_profile.php?id='.$user_location['uID'].'" target="_blank"><u><b>'.$user_location['uLogin'].'</b></u></a><br />'; } if ($grid_x == $users_map['x'] && $grid_y == $users_map['y']) { $building = '<img src="images/map/building.gif" alt="" border="0" /><br />'; $user_map_name = '<br /><a href="player_profile.php?id='.$users_map['uID'].'" target="_blank"><u><b>'.$users_map['uLogin'].'</b></u></a><br />'; } echo "<td width=\"75\" height=\"75\" style=\"background-image: url('images/map/$bgimg');background-repeat: repeat;\" align=center valign=center onclick=\"window.location.href='map.php?xcord=$grid_x&ycord=$grid_y'\">$building $user_map_name</td>"; } require 'includes/footer.php'; ?> I want to pull the last 8 entries from a database. Code: [Select] $result = mysql_query("SELECT * FROM `sites` ORDER BY id DESC LIMIT 8"); The problem is when I ORDER BY ASC the elements are displayed fine but in ORDER BY DESC the are messed up. Why? and how do I fix it ORDER BY DESC ORDER BY ASC CSS Code: [Select] html { font-family: segoe ui, arial, helvetica, sans-serif; height: 100%; overflow: hidden; } body { background-image: linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -o-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -moz-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -webkit-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -ms-linear-gradient(bottom, #FFFFFF 16%, #E8E8E8 79%); background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0.16, #FFFFFF),color-stop(0.79, #E8E8E8)); background-repeat: no-repeat; } #sites { width: 56%; padding: 10px; position: relative; left: 50%; margin-left: -29%; top: 150px; } .siteWidget { margin: 5px; padding: 10px; width: 200px; float: left; text-align: center; -webkit-transition: all 0.25s ease-in-out; -moz-transition: all 0.25s ease-in-out; } .siteWidget .img { height: 150px; -moz-box-shadow: 2px 2px rgba(0,0,0,0.25); -webkit-box-shadow: 2px 2px rgba(0,0,0,0.25); box-shadow: 2px 2px rgba(0,0,0,0.25); margin-bottom: 10px; } .siteWidget .img:hover { box-shadow: 0 0 10px rgba(0, 0, 0, 1); -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 1); -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 1); } a { text-decoration: none; colour: black; } a:visited { color: black; } a:hover { color: #e90000; } h3 { margin: 0; padding: 0; } html/PHP Code: [Select] <? ob_start(); include('config.php'); ?> <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>Site Selector</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php if (!isset($_POST['submit'])) { ?> <form action="index.php" method="post"> <table> <tr> <td> <h3>Add New Site: </h3> </td> <td> <input type="text" name="siteName" placeholder="Name" /> </td> <td> <input type="text" name="siteUrl" placeholder="URL" /> </td> <td> <input type="submit" name="submit" value="Add Site" /> </td> </tr> </table> </form> <div id="sites"> <?php //load the pages from the Database $result = mysql_query("SELECT * FROM `sites` ORDER BY id ASC LIMIT 8"); if (mysql_num_rows($result) == 0) { echo 'No entries'; } else { while ($row = mysql_fetch_assoc($result)) { ?> <div class="siteWidget"> <div class="img"><a href="http://<?=$row['url']?>"><img src="http://pagepeeker.com/t/m/<?=$row['url']?>" border="0"></a></div> <a href="http://<?=$row['url']?>" name="<?=$row['name']?>"><?=$row['name']?></a> </div> <? } } } else { //Get the data $siteName = secure($_POST['siteName']); $siteUrl = secure($_POST['siteUrl']); if (!$siteName || $siteUrl) { header("Location: index.php"); } else { $query = mysql_query("INSERT INTO `sites` (name, url) VALUE($siteName, $siteUrl)"); if (mysql_num_rows($query)) { header("Location: index.php"); } else { echo 'Site not Added!<br />'; echo '<a href="index.php">Go Back</a>'; } } } ?> <div style="clear:both;"></div> </div> </body> </html> HTML ONLY Code: [Select] <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>Site Selector</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <form action="index.php" method="post"> <table> <tr> <td> <h3>Add New Site: </h3> </td> <td> <input type="text" name="siteName" placeholder="Name" /> </td> <td> <input type="text" name="siteUrl" placeholder="URL" /> </td> <td> <input type="submit" name="submit" value="Add Site" /> </td> </tr> </table> </form> <div id="sites"> <div class="siteWidget"> <div class="img"><a href="http://google.ca"><img src="http://pagepeeker.com/t/m/google.ca" border="0"></a></div> <a href="http://google.ca" name="Google">Google</a> </div> <div class="siteWidget"> <div class="img"><a href="http://facebook.com"><img src="http://pagepeeker.com/t/m/facebook.com" border="0"></a></div> <a href="http://facebook.com" name="Facebook">Facebook</a> </div> <div class="siteWidget"> <div class="img"><a href="http://coldcallradio.com"><img src="http://pagepeeker.com/t/m/coldcallradio.com" border="0"></a></div> <a href="http://coldcallradio.com" name="Cold Call Radio">Cold Call Radio</a> </div> <div class="siteWidget"> <div class="img"><a href="http://redbarradio.net"><img src="http://pagepeeker.com/t/m/redbarradio.net" border="0"></a></div> <a href="http://redbarradio.net" name="Red Bar Radio">Red Bar Radio</a> </div> <div class="siteWidget"> <div class="img"><a href="http://youtube.com"><img src="http://pagepeeker.com/t/m/youtube.com" border="0"></a></div> <a href="http://youtube.com" name="YouTube">YouTube</a> </div> <div class="siteWidget"> <div class="img"><a href="http://coldcallradio.com/wp-admin"><img src="http://pagepeeker.com/t/m/coldcallradio.com/wp-admin" border="0"></a></div> <a href="http://coldcallradio.com/wp-admin" name="Cold Call Radio Admin Panel">Cold Call Radio Admin Panel</a> </div> <div class="siteWidget"> <div class="img"><a href="http://apple.ca"><img src="http://pagepeeker.com/t/m/apple.ca" border="0"></a></div> <a href="http://apple.ca" name="Apple Canada">Apple Canada</a> </div> <div class="siteWidget"> <div class="img"><a href="http://trios.com"><img src="http://pagepeeker.com/t/m/trios.com" border="0"></a></div> <a href="http://trios.com" name="triOs College">triOs College</a> </div> <div style="clear:both;"></div> </div> </body> </html> hi trying to make a grid of two columns , data from db using mysqli and php, but it does not work...can you guys help me thanks in advance
<?php echo"<table border='0' align='center' cellpadding='2' cellspacing='2' width='70%'>";
$query = "SELECT * FROM posts";
while ($row = mysqli_fetch_assoc($select_all_categories_query)){
if($count ==0) { echo"<tr>"; }
echo"<div class='post-img'>"; }else { $count=0;
echo"<div class='post-img'>"; } $count++; } echo"</tr></table>"; ?>
this is the result
i want this kind of result
thank you Hi, I've been trying to figure out a way to create a very large (1000x1000) grid. With each cell being 5x5, so 200 rows and 200 cols. Here is the way I've been doing it: <? $col = 1; while ($col <= 200) { echo("<ul style=\"width: 1000px; height: 5px; border: 0px; margin: 0px; padding: 0px;\">"); $row = 1; while ($row <= 200) { $c1 = "#ffcc00"; $c2 = "#ffff99"; $c3 = "#cfeef6"; $c4 = "#b2ebc5"; $c5 = "#ffffff"; $c6 = "#d7ebff"; $c7 = "#dfceb9"; $c8 = "#b3ccc5"; $number = rand(1,8); $bgcolour = ${"c$number"}; echo("<li style=\"background-color: $bgcolour; width: 5px; height: 5px; float: left; display: inline;\"></li>"); $row = $row + 1; } echo("</ul>"); $col = $col + 1; } ?> It work's, however, as you can imagine it is incredibly slow loading. And browsers such as IE usually end up crashing, even on high end, fast processing PC's, let alone what might happen on an average house hold computer. I've been wondering if there is a more effective method of creating the grid that I am unaware of, I will also be implementing hover boxes (overLib) over each 5x5 cell, which will display dynamic information from a database. And the background color will also be taken from the database and not be decided by the php rand(); like it currently is. So I'm thinking once I start adding more to it, it's going to run even slower than what it is now. I know this is a PHP forum, but if PHP isn't the best answer would anyone think Javascript could make it run smoother? Or is it going to be impossible to create it fast and efficiently no matter what I use? After days of agony, I finally figured out a way to display my blog posts masonry style.
However, I now want to find out if I can make it look exactly (or close to) the static design that I had before which is this :
http://pier36nyc.com/events/
How my dynamic masonry looks like right now on my localhost:
http://postimg.org/image/uy5jb4zax/
This is the code for the masonry:
<script> Code: [Select] <?php $path = "../assets/tattoos/"; $path2 = "../assets/tattoos-thumbs/"; if(isset($_POST['file']) && is_array($_POST['file'])) { foreach($_POST['file'] as $file) { unlink($path. "/" . $file) or die("Failed to delete file"); unlink($path2. "/" . $file) or die("<meta http-equiv=\"refresh\" content=\"0; url=index.php\" />"); } } ?> <form name="form1" method="post"> <?php $imageDir = "../assets/tattoos/"; $dir_handle = @opendir($path) or die("Unable to open folder"); while (false !== ($file = readdir($dir_handle))) { if($file == "index.php") continue; if($file == ".") continue; if($file == "..") continue; echo "<input type='CHECKBOX' name='file[]' value='$file'>"; echo "<img src='../assets/tattoos/$file' style='height:auto;width:8%;' alt='$file'>"; } closedir($dir_handle); ?> <input type="submit" name="Delete" value="Delete"> </form> I have this code, which calls an image directory and adds a checkbox next to it, you check the boxes you wish, hit delete and the pictures are removed from the server. I need them to display in a grid view, like 4 columns by X amount of rows. Any help would be greatly appreciated. |