Jump to content

jaxdevil

Members
  • Posts

    268
  • Joined

  • Last visited

Everything posted by jaxdevil

  1. I want to change the die function of my sql query, if the sql query fails I want to have the following piece of code executed: <body onload="parent.main.location.href='http://<?=$_SERVER[HTTP_HOST]?>/pages/mpl_error.php'"> My current statement is: $sql = "INSERT INTO `products` ( $table_products ) VALUES ( $insert_products_str )"; mysql_query($sql) or die('SQL ERROR:'.mysql_error()); So instead I want to do something like: $sql = "INSERT INTO `products` ( $table_products ) VALUES ( $insert_products_str )"; mysql_query($sql) or print "<body onload=\"parent.main.location.href='http://<?=$_SERVER[HTTP_HOST]?>/pages/mpl_error.php\'">" die('SQL ERROR:'.mysql_error()); Would that work? If not any ideas? Thanks in advance, SK
  2. Ok, I have somewhat of an idea, but I am lost on the last piece of the puzzle. The below code will target the specific columns in the database insert query but not the $values variable, I need to split the array of columns from the csv file into the correct columns from the csv file for each sql insert query in the below function. Any ideas? $table_products = "`categories` , `manufacturer`, `model_number`, `list_price` "; $table_products_description = "`manufacturer` , `model_number`, `description` "; $table_products_media = "`manufacturer`, `model_number`, `image_file`, `pdf_specs`, `pdf_one`, `pdf_two`, `pdf_three`, `pdf_four` "; $table_products_ship = "`manufacturer`, `model_number`, `freight_class`, `ship_from`, `weight`, `height`, `width`, `depth` "; $handle = fopen("product_update.csv", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { foreach( $data as $v ) { $insertValues="'".addslashes(trim($v))."'"; } $values=inplode(',',$insertValues); $sql = "INSERT INTO `products` ( $table_products ) VALUES ( $values )"; mysql_query($sql) or die('SQL ERROR:'.mysql_error()); $sql = "INSERT INTO `products_description` ( $table_products_description ) VALUES ( $values )"; mysql_query($sql) or die('SQL ERROR:'.mysql_error()); $sql = "INSERT INTO `products_media` ( $table_products_media ) VALUES ( $values )"; mysql_query($sql) or die('SQL ERROR:'.mysql_error()); $sql = "INSERT INTO `products_ship` ( $table_products_ship ) VALUES ( $values )"; mysql_query($sql) or die('SQL ERROR:'.mysql_error()); } fclose($handle);
  3. I have a script for uploading csv files into my MySQL Database tables. The problem is it loads one file into one table, what I need it to do is to mark the columns based on the column name and upload each column to the right table. The 4 tables and the columns they contained I listed below: products "categories","manufacturer","model_number","name","list_price" products_description "manufacturer","model_number","description" products_media "manufacturer","model_number","image_file","pdf_specs","pdf_one","pdf_two","pdf_three","pdf_four" products_ship "manufacturer","model_number","freight_class","ship_from","weight","height","width","depth" And here is a copy of the contents of a one line csv file that would be uploaded, just as an example, in normal effect it will be hundreds of lines, but this is just a single line to show what I mean: categories,manufacturer,model_number,name,description,image_file,pdf_specs,pdf_one,pdf_two,pdf_three,pdf_four,freight_class,ship_from,weight,height,width,depth,list_price Cooking|Toasters_and_Toaster_Ovens,APW Wyott,AT-Express,AT Express Radiant Conveyor Toasters,ELECTRIC : 120V 1725W 14.4 Amps 60hz DIMENSIONS : 13 1/4inH x 15 3/64inW x 17 3/16inD LBS : 35,AT-Express.jpg,AT-Express.pdf,,,,,85,"75226 [Dallas, TX]",35,13.25,15.05,17.19,1144 So the base code I use for uploading one file to one database is below, I need to make it work for uploading data from one csv file into separate tables based on the column name. <? $fcontents = file ('./products.csv'); for($i=0; $i<sizeof($fcontents); $i++) { $line = trim($fcontents[$i]); $arr = explode(",", $line); $sql = "insert into `products` values ('". implode("','", $arr) ."')"; mysql_query($sql); echo $sql ."<br>\n"; if(mysql_error()) { echo mysql_error() ."<br>\n"; } } ?> Any ideas? Thanks in advance, SK
  4. I have a section of an invoice (the back legal mumbo jumbo) and on the page I fill out all the data I do not want it showing, but when I print the page I want it to show up. I know how to block specific divs from being printed but still be displayed, but what I want to do with this one is just the opposite, block it from display but include it in the print. Any ideas? Thanks, SK
  5. I have a form on my site that has a vendor name and address section and next to it a 'ship to' name and address section. I have used an ajax script before that will search through a database as I type and will display a drop down below the form field of the first 5 names that match that name from the database, and if you select one it fills the form with the name or ID number for that name. (sort of like ask.com does) but what I need to do is this: Each name and address section (both the vendor and ship to sections) have 6 fields (name, address, city/state/zip, phone, fax, contact) that are stored in their own databases (their is a vendor database and a 'ship to' database) the vendor database has a column for 'ship to links' where all previously 'ship to' entries are stored in the 'ship to database' and the ids for each of those are listed on the column 'ship_to_links' and separated by a delimiter ( | ). What I need is an ajax script that will first while the user is typing in the vendor name it is auto searching the vendor database and displays the first 5 entries, then is the user clicks one it auto-fills the rest of that form fields (for the vendor database) AND it selects the first ship_to id in the list of ship_tos and fills in the second form field with the data form the 'ship to' database for that first entry. If there are multiple form fields it will display a drop down field on the name of the ship to location where they can select a different one, and will allow them if they like to type in a new ship to location. Anyone seen an ajax script that works similar to this? Thanks in advance, SK
  6. I figured it out. I used this bit of code: <SCRIPT language="JavaScript"> function submitform() { document.myform.submit(); } </SCRIPT> Named the form 'myform' and made the link in the flash point to: 'javascript: submitform()' So it submits the form when the link is clicked even though the link is before the form. Hope this helps someone
  7. I have a form and I have a flash component that sits at the top of each page that runs off of a .inf file where I can set URLs to open when clicking icons within the flash file. So I have a form that would reside on the page, but as you can tell the flash file is at the top of the page and it makes a nice clean looking menu like a windows menu with file, edit, view, etc. so I can click file and it drops down and has a 'save' command. So I would like to be able to fill out the form and click the 'save' button in the flash file and have the form submit. The only thing that the flash file can do is open a url, so I am trying to figure out a method to submit the form with a link that resides ABOVE the form itself. Any ideas? Some ideas I have been mulling around are an iframe that I can target with the flash (the option to target the link is available as a feature of the inf file.) So is there a way I can target a submit button in an iframe below the form that has a an 'onload' function that autosubmits the form submit button onload, that way when I click the save button in the flash, the iframe is loaded containing an onload submit button so it submits the form when the flash link is clicked? Or maybe the submit button is a transparent gif below the form with a submit javascript applied when some other area is loaded and the link loads that area in a different iframe. Any ideas? Thanks, SK
  8. Never mind, I figured it out. I just added $count = $count+1; right above $output SK
  9. I am using php and mysql to dynamically generate an INF file based on files I have the names to in a database. I am trying to make each set of results increment in number. I.E. the output should be like this: &image1= &URL1= &Message1= (next row below) &image2= &URL2= &Message2= (and so forth) Right now I simply places the variable $count where the numbers should go. How can I make that variable ( $count) be a number 1 for the first row, and a number 2 for the next row, and so on? Below is the code I am using now: <?php $database = "xxx"; $dbconnect = mysql_pconnect('xxx','xxx','xxx'); mysql_select_db($database, $dbconnect); $query = "select `image_one` FROM `images` WHERE `image_one` != 'missing'"; $result = mysql_query($query, $dbconnect); while ($line = mysql_fetch_assoc($result)) { $return[] = $line; } $output = "Applet=PicStrip &ID=PicStrip &Width=400 &Height=100 &PageBgColor=F0F0FF &Accelerate=Yes &AlignTops=Yes &BgColor=F0F0FF &BorderColor=A00000 &BorderWidth=1 &ChangeDirection=No &ClickDown=Yes &DefaultTarget=_self &FocusTint=No &HotSpotWidth=400 &LoadProgressBorderColor=525461 &LoadProgressFillColor=B0B7E3 &LoadText=Loading images... &LoadTextColor=000000 &MaskWidth=25 &Name=PicStrip &ScrollAmount=15 &ScrollDelay=10 &ScrollFromMouse=Yes &ShowMasks=No &ShowVersion=No &SoundClick=5sounddown.mp3 &SoundRelease=5soundup.mp3 &Spacing=5 &StartScrollFrom=Right &Testmode=No &TintColor=FFFFFF &Transparent=No &TransparentScrollAmount=55 &TransparentScrollDelay=10"; foreach ($return as $line) { $output .= " &image".htmlentities($count)."=/prod_images/thumbs/".htmlentities($line['image_one']).".jpg &URL".htmlentities($count)."=/index.php?region=en&ctm=no&medical=Product&code=".htmlentities($line['image_one'])." &Message".htmlentities($count)."=".htmlentities($line['image_one'])." "; } echo $output; ?>
  10. I have language files I want to be editable by the user. So I have a form that will pull all the DEFINE entries as form fields, which they can then edit how they want, then when the form is posted I want it to put those variables (each lines new value) into a spot on a new language file and write it to the server, overwriting the old one. How do you do this?
  11. Ok, I don't know what I was thinking when I did this but here I am, so I need to find a solution. I made a query to select the distinct rows, then I made a new field in the table (numerical) to sort the results. After I added the 'ORDER BY' to the end I realized how foolish that was. So what can I do to sort this query by a field other than the distinct one? Here is the query: "$sql_make = "SELECT DISTINCT `cat` FROM cats_$region ORDER BY `sort` ASC"
  12. That was it man, I appreciate your help greatly! Thanks a million! SK
  13. I have my database setup where EVERY cell for image_one, image_two, and image_three for every model (column `mod`) is the text 'missing'. Now what is happening is that somehow in the below code it is sending the output to not equal to 'missing', when they are equal to missing. What could this be? <?php if ( $medical == "Product") { ?> <? $images_query = "SELECT * FROM `images` WHERE `mod` = '$code' LIMIT 1"; $images_result = mysql_query($images_query) or die(mysql_error()); while($row = mysql_fetch_array($images_result)) { if ( $image_one != "missing") { $image_one = "/prod_images/".$code."/".$row['image_one'].".jpg"; } if ( $image_one == "missing") { $image_one = "/prod_images/missing.jpg"; } if ( $image_two != "missing") { $image_two = "/prod_images/".$code."/".$row['image_two'].".jpg"; } if ( $image_two == "missing") { $image_two = "/prod_images/missing.jpg"; } if ( $image_three != "missing") { $image_three = "/prod_images/".$code."/".$row['image_three'].".jpg"; } if ( $image_three == "missing") { $image_three = "/prod_images/missing.jpg"; } $image_mod = $row['mod']; ?>
  14. I figured it out. createThumbs($_SERVER['DOCUMENT_ROOT']."/prod_images/$mod/",$_SERVER['DOCUMENT_ROOT']."/prod_images/$mod/thumbs/","100");
  15. I am trying to create a form that will upload an image and place one copy in a folder and then a thumbnail version in a folder inside that folder called 'thumbs' It says it is uploaded but only the main image is uploaded, the thumbnail never arrives on the server, even though the script completes and displays the success message. Any ideas? I posted the form first below and the upload and convert code below that. <form action="inventory.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <input type="hidden" name="action" value="Upload"> <input type="hidden" name="image" value="One"> <input type="hidden" name="mod" value="<?=$mod_num?>"> <input type="hidden" name="f_name" value="<? echo time(); ?>"> <table width="300"> <tr> <td> Select Image 1: </td> <td> <input name="ufile[]" type="file" id="ufile[]" size="17" /> </td> </tr> </table> <center> <input type="submit" value="upload"> </center> </form> <?php mkdir($_SERVER['DOCUMENT_ROOT']."/prod_images/$mod", 0777); ?> <?php mkdir($_SERVER['DOCUMENT_ROOT']."/prod_images/$mod/thumbs", 0777); ?> <? $path1= $_SERVER['DOCUMENT_ROOT']."/prod_images/temp/".$HTTP_POST_FILES['ufile']['name'][0]; copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); chmod("$path1", 0755); $orig_filename = "$path1"; $new_filename = $_SERVER['DOCUMENT_ROOT']."/prod_images/".$mod."/".$f_name.".jpg"; echo "f_name:".$f_name; echo "mod:".$mod; echo "../prod_images/".$mod."/".$f_name.".jpg"; $status = rename($orig_filename, $new_filename) or exit("Could not add the item"); echo "Item added successfully!"; ?> <?php function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth ) { // open the directory $dir = opendir( $pathToImages ); // loop through it, looking for any/all JPG files: while (false !== ($fname = readdir( $dir ))) { // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if ( strtolower($info['extension']) == 'jpg' ) { // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img,"{$pathToThumbs}{$fname}") or die ("Could not create image from JPEG"); } } // close the directory closedir( $dir ); } // call createThumb function and pass to it as parameters the path // to the directory that contains images, the path to the directory // in which thumbnails will be placed and the thumbnail's width. // We are assuming that the path will be a relative path working // both in the filesystem, and through the web for links createThumbs("../prod_images/".$mod,"../prod_images/".$mod."/thumbs/","100"); chmod("http://".$_SERVER['HTTP_HOST']."/prod_images/".$mod."/thumbs/".$f_name.".jpg", 0755); $orig_filename = "http://".$_SERVER['HTTP_HOST']."/prod_images/".$mod."/".$f_name.".jpg"; echo $orig_filename; $new_filename = "http://".$_SERVER['HTTP_HOST']."/prod_images/".$mod."/thumbs/".$f_name.".jpg"; echo $new_filename; echo "Full Size Image Added successfully!"; $query = "UPDATE images SET `image_one`='$f_name' WHERE `mod`='$mod'"; mysql_query($query) or die( "An error has ocured: " .mysql_error (). ":" .mysql_errno ()); print "<h1>Inventory Update Successful</h1><br>data<br /><br /><em>Updated!</em><br /><br />"; ?>
  16. I am trying to make a function that will display a color jpeg icon (the jpeg symbol) if all three image fields in the database have images loaded. The default for the cell is 'missing', so it is looking first to see if all the image cells are equal to 'missing', if they are it displays a grayscale jpeg icon, if all the cells do not equal 'missing' then it goes to the next set of if statements, which the next two look to see if some of the cells are equal to 'missing', if some of them have the value of 'missing' and at least 1 that the value is not 'missing' (meaning an image filename is loaded to at least one of the cells), if one of those matches then it will display a half grayscale, half color jpeg icon, if that is not a match then it checks to see if all the cells are not equal to 'missing', which would mean there are image filenames loaded all of the image cells, if there are then it will display a full color jpeg icon. Below is my code. On line 14 it is saying (in PHP Designer 2008) "syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING or T_VARIABLE or T_NUM_STRING" I don't know what to do. Anyone can help? <?php function displayPhoto($photo_code) { $photo_query = "SELECT * FROM images WHERE `mod` = '$photo_code' LIMIT 1"; $photo_result = mysql_query($photo_query) or die(mysql_error()); while($photo_row = mysql_fetch_array($photo_result)) { if ($photo_row['image_one'] == "missing") { if ( $photo_row['image_two'] == "missing") { if ( $photo_row['image_three'] == "missing") { echo "<img src=\"images/no_jpeg.gif\" border=\"0\">; } } } if ($photo_row['image_one'] != "missing") { if ($photo_row['image_two'] == "missing") { if ($photo_row['image_three'] == "missing") { echo "<img src=\"images/half_jpeg.gif\" border=\"0\">; } } } if ($photo_row['image_one'] != "missing") { if ($photo_row['image_two'] != "missing") { if ($photo_row['image_three'] == "missing") { echo "<img src=\"images/half_jpeg.gif\" border=\"0\">; } } } if ($photo_row['image_one'] != "missing") { if ($photo_row['image_two'] != "missing") { if ($photo_row['image_three'] != "missing") { echo "<img src=\"images/jpeg.gif\" border=\"0\">; } } } } } ?>
  17. I tried, its not working. I redid the code to be an echo instead of the heredoc thing, and I am trying to call the code as a function, but its not working. I am copying the function I made below and the way I am trying to call it, its not working so maybe you can see what I am doing wrong? <?php function displayIcon($icon_code) { if ( $icon_code == "yes") { ?> <img src="images/active.gif" border="0"> <? } if ( $icon_code == "no") { ?> <img src="images/inactive.gif" border="0"> <? } } $icon_r = displayIcon(yes); echo "{$icon_r}"; ?>
  18. Can I make a function outside of it and call it from within inside the curly brackets?
  19. I have a code I use to display items from my database and paginate them. The html portion is inside a container that starts with <<<HTML and ends with HTML; , I do not know what that is. Inside the code I am trying to run a small php if statement and it won't work inside of it. What kind of container is this code and how can I run php inside of it? Here is the code I am trying to run inside of it and below is the entire page, you will see where the code is at and the <<<HTML container, whatever that is. BTW all the code calls inside of it are inside curly brackets, if that helps to figure out what kind of container it is. <? if ( $act == "yes") { ?> <img src="images/active.jpg" border="0"> <? } if ( $act == "no") { ?> <img src="images/inactive.jpg" border="0"> <? } else { ?> <img src="images/active.jpg" border="0"> <? } ?> <?php // $Id: desktop.php,v 0.1 2007/07/25 16:54:40 xsds Exp $ // include common files require_once("includes/common.inc.php"); validateAdmin(); $msg = get_message(); ?> <!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=iso-8859-1" /> <title><?php print $config['siteAdminTitle']?></title> <link href="css/css.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top" bgcolor="#FFFFFF" class="white-bg"><?php include("includes/header.inc.php"); ?></td> </tr> <tr> <td align="center" valign="top" bgcolor="#FFFFFF" class="white-bg paddingright10"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td height="25" colspan=4> </td></tr> <tr> <?php require_once("includes/leftpanel.inc.php");?> <!-- BODY START--> <td width="100%" align="center" valign="top" bgcolor="#EEEEEE" class="border-rt"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="middle" class="header_bg "><img alt="Admin Panel" src="images/heading_icon.gif" width="16" height="16" hspace="5" align="left" /><span class="h1">Language Modules Admin </span></td> </tr> <tr> <td> </td> </tr> <tr> <td align="center" valign="top"><table width="94%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <?php require( $_SERVER['DOCUMENT_ROOT']."/configs/connection.php"); ?> <?php // Select total results for pagination $result = mysql_query("SELECT count(*) FROM langs") or die(mysql_error()); $num_records = mysql_result($result,0,0); // Set maximum number of rows and columns $max_num_rows = 25; $max_num_columns = 1; $per_page = $max_num_columns * $max_num_rows; // Work out how many pages there are $total_pages = ceil($num_records / $per_page); // Get the current page number if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; // Work out the limit offset $start = ($page - 1) * $per_page; // Select the results we want including limit and offset $result = mysql_query("SELECT `lang` FROM langs LIMIT $start, $per_page") or die(mysql_error()); $lang = mysql_query("SELECT `lang` FROM langs LIMIT $start, $per_page") or die(mysql_error()); $name = mysql_query("SELECT `name` FROM langs LIMIT $start, $per_page") or die(mysql_error()); $act = mysql_query("SELECT `act` FROM langs LIMIT $start, $per_page") or die(mysql_error()); $custom = mysql_query("SELECT `custom` FROM langs LIMIT $start, $per_page") or die(mysql_error()); $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = ceil(mysql_num_rows($result)/$num_columns); // Echo the results ?> <table width="550" border="1" bordercolor="black" cellpadding="0" cellspacing="0" style="border-left-width:0px; border-top-width: 1px; border-bottom-width: 0px; border-right-width: 0px;"> <tr width="550"> <td width="50"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Status</font></b> </td> <td width="270"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Language</font></b> </td> <td width="40"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Flag</font></b> </td> <td width="150"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Set Option</font></b> </td> <td width="40"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Edit Module</font></b> </td> </tr> <? for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr width=\"550\" height=\"5\">\n"; for ($c = 0; $c < $max_num_columns; $c++){ // 1 $x = $r * $max_num_columns + $c; if ($x < mysql_num_rows($result)){ $lang_r = mysql_result($lang, $x, 0); $name_r = mysql_result($name, $x, 0); $act_r = mysql_result($act, $x, 0); $custom_r = mysql_result($custom, $x, 0); $y = <<<HTML <td width="50" valign="middle"> <center> <? if ( $act == "yes") { ?> <img src="images/active.jpg" border="0"> <? } if ( $act == "no") { ?> <img src="images/inactive.jpg" border="0"> <? } else { ?> <img src="images/active.jpg" border="0"> <? } ?> </center> </td> <td width="270" align="center" valign="middle"> {$name_r} </td> <td width="40" valign="middle"> <center> <img src="/flags/{$lang_r}.gif" border="0"> </center> </td> <form action="" method="post"> <td width="150" valign="middle"> <center> <SELECT NAME="lang_opt" style="width:225px; border:0px solid; height:17px; padding:0px 3px; position:relative;" onchange='this.form.submit()'> <OPTION VALUE="NONE">-----Select Action----- <font style="font-size: 0.7em;" face="Tahoma"> <OPTION VALUE="Active">Active <OPTION VALUE="Inactive">Inactive <OPTION VALUE="Custom">Custom </font> </SELECT> </center> </td> </form> <td width="40"> <center> <a href="lang_mod.php?lang={$lang_r}"><img src="images/edit.gif" border="0"></a> </center> </td> HTML; } else { $y = ''; } echo "$y"; } echo "</tr>\n"; } // Echo page numbers echo "</table></center><center>\n"; echo "<table width=480 cellspacing=0 cellpadding=0 border=0><tr><td><font face=\"Tahoma,Verdana,Arial\" size=0.50em><center>Go to: "; // Echo the results for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?action=List&page=$i\">$i</a> ";} ?> </font></center></td></tr></table> </div> </font> </div> <br> </td> </tr> </table></td> </tr> <?php if(check_not_null($msg)) { ?> <tr> <td align="center"><?php echo $msg; ?></td> </tr> <?php } ?> <tr> <td> </td> </tr> </table></td> </tr> </table> </td> </tr> <tr> <td align="center" valign="top" class="white-bg"> </td> </tr> <tr> <td align="center" valign="top" bgcolor="#94A1B0"><?php include("includes/footer.inc.php"); ?></td> </tr> </table> </body> </html>
  20. Does NO one have an idea on this? I don't understand why no one has been able to answer the last few posts I made. Either someone posts something totally irrelevant or they just don't post at all. I am obviously not frustrated at anyone on here, just this problem, but it doesn't help when I am genuinely stuck and can't get any help. The last few posts I have looked for help on here for I actually had to solve myself, so its beginning to be a habit. It seems like there are quite a bit of people on here with programs like PhpDesigner and the like who just run through these posts, copy and paste the persons code, and then just type in whatever error the program displays.
  21. I have a pagination code that works on one site, but I changed the database fields it is pulling for this site I copied it to and it is not working. It is made to display 25 rows, then paginate. Well it works fine on one site, then I change ONLY the connection setting and the rows it is pulling from the database and it then will display the first rows data, it pulls 25 rows, it is in a table and creates the table with all 25 rows, but only populates the first one with data. Anyone have an idea on this one? I put the one I am using below. That is the one that is not working, below that I copied the code I am using on the site that IS working. <?php require( $_SERVER['DOCUMENT_ROOT']."/configs/connection.php"); ?> <?php if ( $action== "List" ) { // Select total results for pagination $result = mysql_query("SELECT count(*) FROM prod WHERE `mod` LIKE '%'") or die(mysql_error()); $num_records = mysql_result($result,0,0); // Set maximum number of rows and columns $max_num_rows = 25; $max_num_columns = 1; $per_page = $max_num_columns * $max_num_rows; // Work out how many pages there are $total_pages = ceil($num_records / $per_page); // Get the current page number if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; // Work out the limit offset $start = ($page - 1) * $per_page; // Select the results we want including limit and offset $result = mysql_query("SELECT `mod` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $cat = mysql_query("SELECT `cat` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $sub = mysql_query("SELECT `sub` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $man = mysql_query("SELECT `man` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $mod = mysql_query("SELECT `mod` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $descrip = mysql_query("SELECT `descrip` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $pri = mysql_query("SELECT `pri` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $lea = mysql_query("SELECT `lea` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $star = mysql_query("SELECT `star` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $star_pri = mysql_query("SELECT `star_pri` FROM prod LIMIT $start, $per_page") or die(mysql_error()); $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = ceil(mysql_num_rows($result)/$num_columns); // Echo the results ?> <table width="500" border="1" bordercolor="black" cellpadding="0" cellspacing="0" style="border-left-width:0px; border-top-width: 1px; border-bottom-width: 0px; border-right-width: 0px;"> <tr width="500"> <td width="40"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Export</font></b> </td> <td width="25"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Delete</font></b> </td> <td width="25"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Edit</font></b> </td> <td width="160"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Model</font></b> </td> <td width="250"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Description</font></b> </td> <td width="50"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Price</font></b> </td> </tr> <? for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr width=\"500\" height=\"5\">\n"; for ($c = 0; $c < $max_num_columns; $c++){ // 1 $x = $r * $max_num_columns + $c; if ($x < mysql_num_rows($result)){ $cat = mysql_result($cat, $x, 0); $sub = mysql_result($sub, $x, 0); $man = mysql_result($man, $x, 0); $mod = mysql_result($mod, $x, 0); $descrip = mysql_result($descrip, $x, 0); $pri = mysql_result($pri, $x, 0); $lea = mysql_result($lea, $x, 0); $star = mysql_result($star, $x, 0); $star_pri = mysql_result($star_pri, $x, 0); $y = <<<HTML <td width="40" align="center" valign="middle"> <a href="ebay_generator.php?mod={$mod}" target="_blank"><img src="images/ebaybutton.gif" border="0"></a> </td> <form action="inventory.php"> <td width="25" valign="middle"> <center> <font face="Tahoma,Verdana,Arial" size="0.80em"> <input type="hidden" name="action" value="Remove"> <input type="hidden" name="cat" value="{$cat}"> <input type="hidden" name="sub" value="{$sub}"> <input type="hidden" name="man" value="{$man}"> <input type="hidden" name="mod" value="{$mod}"> <input type="hidden" name="oldmod" value="{$mod}"> <input type="hidden" name="descrip" value="{$descrip}"> <input type="hidden" name="pri" value="{$pri}"> <input type="hidden" name="lea" value="{$lea}"> <input type="hidden" name="star" value="{$star}"> <input type="hidden" name="star_pri" value="{$star_pri}"> <input type="image" src="images/drop.gif" border="0"></font> </center> </td> </form> <form action="" method="post"> <td width="25" valign="middle"> <center> <font face="Tahoma,Verdana,Arial" size="0.80em"> <input type="hidden" name="action" value="Edit"> <input type="hidden" name="cat" value="{$cat}"> <input type="hidden" name="sub" value="{$sub}"> <input type="hidden" name="man" value="{$man}"> <input type="hidden" name="mod" value="{$mod}"> <input type="hidden" name="oldmod" value="{$mod}"> <input type="hidden" name="descrip" value="{$descrip}"> <input type="hidden" name="pri" value="{$pri}"> <input type="hidden" name="lea" value="{$lea}"> <input type="hidden" name="star" value="{$star}"> <input type="hidden" name="star_pri" value="{$star_pri}"> <input type="image" src="images/edit.gif" border="0"></font> </center> </td> </form> <td width="160"> <font face="Tahoma,Verdana,Arial" size="0.80em">{$mod}</font> </td> <td width="250"> <font face="Tahoma,Verdana,Arial" size="0.80em">{$descrip}</font> </td> <td width="50"> <font face="Tahoma,Verdana,Arial" size="0.80em">{$pri}</font> </td> HTML; } else { $y = ''; } echo "$y"; } echo "</tr>\n"; } // Echo page numbers echo "</table></center><center>\n"; echo "<table width=480 cellspacing=0 cellpadding=0 border=0><tr><td><font face=\"Tahoma,Verdana,Arial\" size=0.50em><center>Go to: "; // Echo the results for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?action=List&page=$i\">$i</a> ";} ?> </font></center></td></tr></table> </div> </font> </div> <br> <? } ?> Now here is the code that DOES work: <?php require( $_SERVER['DOCUMENT_ROOT']."/configs/connection.php"); ?> <?php if ( $action== "List" ) { // Select total results for pagination $result = mysql_query("SELECT count(*) FROM products WHERE `active`='Yes'") or die(mysql_error()); $num_records = mysql_result($result,0,0); // Set maximum number of rows and columns $max_num_rows = 25; $max_num_columns = 1; $per_page = $max_num_columns * $max_num_rows; // Work out how many pages there are $total_pages = ceil($num_records / $per_page); // Get the current page number if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; // Work out the limit offset $start = ($page - 1) * $per_page; // Select the results we want including limit and offset $result = mysql_query("SELECT `mod` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $cat = mysql_query("SELECT `cat` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $subcat = mysql_query("SELECT `subcat` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $man = mysql_query("SELECT `man` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $maker = mysql_query("SELECT `man` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $mod = mysql_query("SELECT `mod` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $name = mysql_query("SELECT `name` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $named = mysql_query("SELECT `name` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $list = mysql_query("SELECT `list` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $priced = mysql_query("SELECT `price` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $cost = mysql_query("SELECT `price` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $specs = mysql_query("SELECT `specs` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $pdf = mysql_query("SELECT `pdf` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $active = mysql_query("SELECT `active` FROM products WHERE `active`='Yes' LIMIT $start, $per_page") or die(mysql_error()); $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = ceil(mysql_num_rows($result)/$num_columns); // Echo the results ?> <table width="500" border="1" bordercolor="black" cellpadding="0" cellspacing="0" style="border-left-width:0px; border-top-width: 1px; border-bottom-width: 0px; border-right-width: 0px;"> <tr width="500"> <td width="40"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Export</font></b> </td> <td width="25"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Delete</font></b> </td> <td width="25"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Edit</font></b> </td> <td width="250"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Manufacturer</font></b> </td> <td width="160"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Model</font></b> </td> <td width="50"> <b><font face="Tahoma,Verdana,Arial" size="0.90em">Price</font></b> </td> </tr> <? for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr width=\"500\" height=\"5\">\n"; for ($c = 0; $c < $max_num_columns; $c++){ // 1 $x = $r * $max_num_columns + $c; if ($x < mysql_num_rows($result)){ // $y = mysql_result($result, $x, 0); // Commented out so I could show your example $num = mysql_result($result, $x, 0); $name = mysql_result($named, $x, 0); $make = mysql_result($maker, $x, 0); $price = mysql_result($priced, $x, 0); $cost = mysql_result($cost, $x, 0); $cat = mysql_result($cat, $x, 0); $subcat = mysql_result($subcat, $x, 0); $man = mysql_result($man, $x, 0); $mod = mysql_result($mod, $x, 0); $list = mysql_result($list, $x, 0); $specs = mysql_result($specs, $x, 0); $pdf = mysql_result($pdf, $x, 0); $active = mysql_result($active, $x, 0); $unformated_price = $price; $price = number_format($unformated_price, 2, '.', ','); $y = <<<HTML <td width="40" align="center" valign="middle"> <a href="ebay_generator.php?mod={$num}" target="_blank"><img src="images/ebaybutton.gif" border="0"></a> </td> <form action="admin.php"> <td width="25" valign="middle"> <center> <font face="Tahoma,Verdana,Arial" size="0.80em"> <input type="hidden" name="action" value="Remove"> <input type="hidden" name="cat" value="{$cat}"> <input type="hidden" name="subcat" value="{$subcat}"> <input type="hidden" name="man" value="{$make}"> <input type="hidden" name="mod" value="{$mod}"> <input type="hidden" name="oldmod" value="{$mod}"> <input type="hidden" name="name" value="{$name}"> <input type="hidden" name="list" value="{$list}"> <input type="hidden" name="price" value="{$price}"> <input type="hidden" name="specs" value="{$specs}"> <input type="hidden" name="pdf" value="{$pdf}"> <input type="hidden" name="active" value="No"> <input type="image" src="images/drop.gif" border="0"></font> </center> </td> </form> <form action="admin.php" method="post"> <td width="25" valign="middle"> <center> <font face="Tahoma,Verdana,Arial" size="0.80em"> <input type="hidden" name="action" value="Edit"> <input type="hidden" name="cat" value="{$cat}"> <input type="hidden" name="subcat" value="{$subcat}"> <input type="hidden" name="man" value="{$make}"> <input type="hidden" name="mod" value="{$mod}"> <input type="hidden" name="name" value="{$name}"> <input type="hidden" name="list" value="{$list}"> <input type="hidden" name="price" value="{$price}"> <input type="hidden" name="specs" value="{$specs}"> <input type="hidden" name="pdf" value="{$pdf}"> <input type="hidden" name="active" value="{$active}"> <input type="image" src="images/edit.gif" border="0"></font> </center> </td> </form> <td width="250"> <font face="Tahoma,Verdana,Arial" size="0.80em">{$make}</font> </td> <td width="160"> <font face="Tahoma,Verdana,Arial" size="0.80em">{$num}</font> </td> <td width="50"> <font face="Tahoma,Verdana,Arial" size="0.80em">{$price}</font> </td> HTML; } else { $y = ''; } echo "$y"; } echo "</tr>\n"; } // Echo page numbers echo "</table></center><center>\n"; echo "<table width=480 cellspacing=0 cellpadding=0 border=0><tr><td><font face=\"Tahoma,Verdana,Arial\" size=0.50em><center>Go to: "; // Echo the results for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?action=List&page=$i\">$i</a> ";} ?> </font></center></td></tr></table> </div> </font> </div> <br> <? } ?>
  22. Ok, here is something that is working. I had to put it on the main index page AND the header file: <? if ( $region == "") { echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?region=en&medical=".$medical."\">"; } ?>
  23. Ok, let me explain a little more what I am trying to do. I had figured out that this here: "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; Gives me what I need, but I can't seem to get the entire function to work. What I have is a site that sets the language file to pull from based on what the variable region is set to in the url. The problem is on the main page no region file is set. So I am looking to make a function that detects if the current location is http://thewebsiteaddress.com/index.php or if the location is http://thewebsiteaddress.com/index.php?region= (i.e. region is blank) and if those are true it redirects the page to http://thewebsiteaddress.com/index.php?region=en (for region is english) BUT I don't want to make the websiteaddresses o be static as I want to be able to load this entire site onto different sites without having to go back in and change the url on these pages. I posted the code I tried but that was not working. Any ideas?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.