PHP - Grid Problems
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> Similar TutorialsHey 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. 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'; ?> How i can create alphabetic grid . like on this website http://www.vietnamworks.com/jobseekers/search.php 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. 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. 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. Hello 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 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 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! 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? I don't want to use AI, or a primary key to sort the data, as it could create some problems if the items are visited out of order, but I want to sort it always based upon a single element for speed.
I'm creating a table that will be populated (built), when it's corresponding entry doesn't exist, how do I get it sorted out if someone visits 2, then 7 before they visit 5 to read what's there? It's not a 2d number line, but a 3d number grid.
Edited by Q695, 09 September 2014 - 11:30 PM. This might be a bit hard to explain! I have a grid, 32x32 which is actually 1024 mySQL rows in a table, you can see the table he http://interbitlotto.com/grid each cell is a row in the database, top left is ID 1, bottom right is id 1024. get it? right well its a battle ship game, and im stuck on the automatic battle ship placement script. I have displayed the generated boats as misses so we can see them. The problem i am having, is that the random number generater chooses a cell too close to the side so the boat ends up wrapping to the other side. I cant think of a way to detect if its going to wrap, if it is then choose another cell... The code below chooses the orientation of the boat, then chooses a random cell... but as you can see, no code for "across" to stop it choosing one too close to the side. Any ideas? Code: [Select] $orientation = rand(1,2); //get random orientation - 1 = down, 2 = across. if ($orientation == 1){ $multiply = 32; //cells till next row $max = 1024 - (32 * $boatlength); //prevents it from choosing a cell too close to the bottom $startcell = rand(1,$max); }else{ $multiply = 1; //across, so next cell $max = 1024; $startcell = rand(1,$max); } 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. 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> This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=327455.0 class curl2{ private $curl_init; private $CURLOPT_URL; public function connect(){ $this->curl_init = curl_init(); } public function debug(){ curl_setopt($this->curl_init, CURLOPT_VERBOSE, TRUE); $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); } public function setUrl($url = null){ $this->CURLOPT_URL = $url; curl_setopt($this->curl_init, CURLOPT_URL, $this->CURLOPT_URL); } public function execute(){ $out = curl_exec($this->curl_init); curl_close($this->curl_init); return $out; } } $curl2 = new curl2; $curl2->connect(); $curl2->setUrl("http://www.linuxformat.co.uk"); $curl2->debug(); echo $curl2->execute(); It display a blank page like attachment result1.jpg, but if I move the $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); from function debug() and join it with function execute() like this: public function execute(){ $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); $out = curl_exec($this->curl_init); curl_close($this->curl_init); return $out; } it return me Linuxformat content ( expected result ) like result2.jpg below is the working code : class curl2{ private $curl_init; private $CURLOPT_URL; public function connect(){ $this->curl_init = curl_init(); } public function debug(){ curl_setopt($this->curl_init, CURLOPT_VERBOSE, TRUE); } public function setUrl($url = null){ $this->CURLOPT_URL = $url; curl_setopt($this->curl_init, CURLOPT_URL, $this->CURLOPT_URL); } public function execute(){ $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); $out = curl_exec($this->curl_init); curl_close($this->curl_init); return $out; } } $curl2 = new curl2; $curl2->connect(); $curl2->setUrl("http://www.linuxformat.co.uk"); $curl2->debug(); echo $curl2->execute(); Why I couldn't split "CURLOPT_STDERR, CURLOPT_RETURNTRANSFER" with "curl_exec" Hello, Alright I am having a few issues here. Let me explain what I am doing...this is a script that allows a customer to split an order..he can split certain items out of one order and it will create another order with the items he split added to this order, and then subtracting the items from the old order. The products are stored in one field called products, they are stored in a delimited list like this qty, product name, price each, product id | qty, product name, price each, product id |etc. Now, before you say why are you storing your products like that?? The reason I have to store my products like so is because the customer does not want the products stored in the order table to be dependent off the products table like they were before. In that case if he modified a product it would modify all of the orders with that product stored in them. Make sense? I am aware a delimited list probably wasn't the best way to do this but it was the best way I could think of. Ok here is my list of issues. 1) Everytime you split an order, it is not creating a new order to store the items that were split into. It created an order the first time I did it, and now all it does is it keeps updating the products field in that order, rather than creating a new order. 2) Next I do not know how I can update the old products (stored in the $prod array). It needs to update the products qtys after the order was split, and then if all of the qty for that product were moved to the new order it just needs to remove that product from the $prod array rather than updating the quantity. The code is below. Please let me know if I can provide any more information to help! Thanks everyone! // Get Old Order $get_order = @mysql_query("SELECT * FROM orders WHERE order_id = {$_POST['order_id']}"); $order = @mysql_fetch_assoc($get_order); // Get Old Order Items $products = $order['products']; //breaking products text down for display $prod = array(); $_products = explode('|', $products); foreach ($_products AS $p) $prod[] = explode(',', $p); /* $get_items = @mysql_query("SELECT product_id, qty FROM order_items WHERE order_id = {$order['order_id']}"); $items = array(); while(($row = @mysql_fetch_assoc($get_items)) !== false) { $items[] = $row; } */ if(empty($prod)) { header("Location: tracking.php"); die(); } // Create New Order mysql_query("INSERT INTO orders SET customer_id = {$order['customer_id']}, order_status = {$order['order_status']}, order_date = '{$order['order_date']}', order_date_paid = '{$order['order_date_paid']}', order_shipping = '{$order['order_shipping']}', order_shipping_fee = '{$order['order_shipping_fee']}', order_insurance = '{$order['order_insurance']}', order_insurance_fee = '{$order['order_insurance_fee']}', order_insurance_total = '{$order['order_insurance_total']}', order_grand_total = '{$order['order_grand_total']}', order_date = '{$order['order_date']}', order_filled = '{$order['order_filled']}', order_ship_date = '{$order['ship_date']}'"); $get_new_order = @mysql_query("SELECT MAX(order_id) AS order_id FROM orders") or die(mysql_error()); $new_order_id = @mysql_result($get_new_order, 'order_id', 0); // Add Items to New Order & Remove Items from Old Order $new_items = array(); $_new_items = ''; foreach($prod as $p2) { for($i = 0; $i < $p2[0]; $i++) { if(!empty($_POST[trim($p2[3]).'_'.$i])) { $new_items[trim($p2[3])]++; } } } //construct new static products list foreach($new_items as $id=>$qty) { $get_product = mysql_query("SELECT name, price FROM products WHERE product_id = '{$id}'"); $got_product = mysql_fetch_assoc($get_product); $_new_items .= $qty.','.$got_product['name'].','.$got_product['price'].','.$id.'|'; //echo $id.' - '.$qty.'<br>'; } //remove last character in products text before going into DB $_new_items = substr_replace($_new_items ,"",-1); //update products field in new order mysql_query("UPDATE orders SET products = '{$_new_items}' WHERE order_id = '{$new_order_id}'"); Hi I have plans in developing a connect function for remote login to my web side. I can't find any useful on Google. Some idees on how to code a API connect button? Something similiar to Facebook connect, Twitter connect etc. BUT this should not rely on facebook api. I'm going to make my own stand alone api. I know I need to use REST in backend, but I'm missing the knowledge to know how to send / recive the login data, and how to know when a user are online or not. I'm greatfull for any help. Also links. And also tips on how to make a developer plattform for apps, much like the way Facebook have it. the image in my comments box wont show up it gives me an error Code: [Select] Notice: Undefined index: avatar in /home/ecabrera/public_html/profile.php on line 277 and i dont whats wrong with it Code: [Select] // display comments $perpage = 10; $start=0; if(@$_GET['s']) $start = $_GET['s']; $query = mysql_query("SELECT * FROM profile_comments WHERE profile_id='$getid' ORDER BY id DESC LIMIT $start, $perpage"); $numrows = mysql_num_rows($query); if ($numrows > 0){ $next = $start + $perpage; $prev = $start - $perpage; while($row = mysql_fetch_assoc($query)){ $user_id = $row['user_id']; $user_name = $row['user_name']; $comment = nl2br($row['comment']); $date = $row['date']; $avatar = $row['avatar']; echo "<img src='avatars/$avatar'></img><a href='$site/profile?id=$getid'></a> <b> on $date</b><br />"; echo "<div style='margin-left: 10px;'>$comment</div><hr>"; } } else echo "This user has no profile comments.<br />"; // end diplay comment area I want to gettwitter feeds, this gives me a xml http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3 based on this: http://www.w3schools.com/PHP/php_xml_simplexml.asp i try to get the xml with: <?php$xml = simplexml_load_file("http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3");?>() i get this error: Quote Warning: simplexml_load_file(http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/vhosting/x/vhost0033377/domains/doekewartena.nl/htdocs/www/temp/twitter03.php on line 2 Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3" in /home/vhosting/x/vhost0033377/domains/doekewartena.nl/htdocs/www/temp/twitter03.php on line 2 i have no clue, i'm very new to php can i even use simplexml_load_file cause it has no .xml file type extention. |