Jump to content

googlit

Members
  • Posts

    52
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

googlit's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks for the help so far.... this is what i have. i have managed to get the form set up but i cannot get it to submit the data to the DB. (code below) im getting this error also: Notice: Undefined index: name in [/size]C:\xampp\htdocs\query.php on line [/size]49 Notice: Array to string conversion in [/size]C:\xampp\htdocs\query.php on line [/size]56 Could not enter data: Unknown column 'Array' in 'field list'[/size] Once again thanks for any help, its very appreciated. <?php $username="****";$password="*****";$host="localhost"; $database="****"; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $sql = "SELECT ps_product.id_product, ps_product.price, ps_product_lang.name FROM ps_product, ps_product_lang WHERE ps_product.id_product = ps_product_lang.id_product"; ?> <table width="500"> <tr> <td width="300"><b>Product</b></td> <td><b>Price</b></td> </tr> </table> <?php $sql = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($sql) > 0) { while ($row_sql = mysql_fetch_assoc($sql)) { echo'<form action="" method="post"> <table width="500"> <tr> <td width="300">'.$row_sql["name"].'</td> <td><input name="price['.$row_sql["id_product"].']" type="text" id="name" value="'.$row_sql["price"].'"></td> <td><input name="update" type="submit" id="update" value="Update"></td> </tr> </table> </form>'; } } ?> <?php if(isset($_POST['update'])) { mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); } $name = $_POST['name']; $price = $_POST['price']; $update = "INSERT INTO ps_product ". " (price) ". " VALUES ". "($price)"; $retval = mysql_query($update); if(! $retval ) { die('Could not enter data: ' . mysql_error()); } echo "Entered data successfully\n"; mysql_close(); ?>
  2. Hi guys, im looking for some help with a little project. i have several tables relating to products and their attributes (price etc). i have created a query that displays the data that i need but i want to be able to edit multiple price fields and then submit the update back to the tables correctly. i have tried several tutorials but cant get it to work. this is my basic query code any help would be a life saver.... Thanks <?php $username="username";$password="tpassword";$host="localhost"; $database="table";mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $sql = "SELECT ps_product.id_product, ps_product.price, ps_product.available_for_order, ps_product_lang.id_product, ps_product_lang.name FROM ps_product, ps_product_lang, ps_manufacturer WHERE ps_product.id_product = ps_product_lang.id_product AND ps_product_lang.id_lang = '2' "; ?> <table width="500"> <tr> <td width="300"><b>Product</b></td> <td><b>Price</b></td> </tr> </table> <?php $sql = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($sql) > 0){ ?> <?php while ($row_sql = mysql_fetch_assoc($sql)){ ?> <?php echo '<table width="500"> <tr> <td width="300">'.$row_sql["name"].'</td> <td>'.$row_sql["price"].'</td> </tr></table>'; ?> <?php } ?> <?php } ?>
  3. Hi all, hoping theres a quick fix for this ive tried a few dif ways but nothing works... i am trying to implement a lightbox into a script which i have and cant seem to get the code right <?php $query = mysql_query("SELECT ID FROM imageArt WHERE isActive='1'"); while($data=mysql_fetch_array($query)) { echo "<img src='view.php?ID=" . $data['ID'] . "' width='200' height='200'>"; } ?> How can i add the code below into the link above?? please help.... <a href="<?php view.php?ID=' . $data['ID'] . '?>" rel="lightbox" title="my caption">mysql/php code here</a> all help appreciated...
  4. Thanks for your help.... problem solved. God i love this forum.... well of to hopefully help some others
  5. Hi, i am wanting to create a simple page with two buttons on, one that says 'start visit', one that says 'end visit', thats the simple bit, here's what i would like the form to do When 'Start Visit' is clicked i would like it to place an entry in the following db: I would like it to add the value "start visit" into the value field, automatically insert todays date into the date field and autonatically insert the time (GMT) into the time field. i have made general form before but have no idea on where to start....... any help would be appreciated
  6. ok, thanks for that, my intention is to have more than 30 records so is there a way to limit per page and to auto calculate the number of pages and asign links etc etc..... can you point me in the right direction thanks for your help so far....
  7. Ok so staring at it for a few more minutes has made me realise the error of my ways: } $id=$_REQUEST['product_id']; //the user id should have been: } $id=$_REQUEST['id']; //the user id but how do i limit results in the querry??
  8. If i had, i wouldn't be here would i? i error states issue with the query however the query runs without issue in navicat/phpmyadmin
  9. Hi all, im wanting to create a basic update script which pulls data from two tables and then puts data to two tables. i am currently getting : Notice: Undefined index: product_id in edit.php on line 26 SQL: select * from jos_vm_product, jos_vm_product_price WHERE jos_vm_product.product_id AND jos_vm_product_price.product_id= >> You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 this is the code i have: my update script which displays the records in the table with a link to the edit form <?php //include database configuration include 'config_open_db.php'; //selecting records $sql="select jos_vm_product.product_id, jos_vm_product.product_name, jos_vm_product.product_s_desc, jos_vm_product_price.product_id, jos_vm_product_price.product_price from jos_vm_product, jos_vm_product_price"; //query the database $rs=mysql_query($sql) or die($sql.">>".mysql_error()); //count how many records found $num=mysql_num_rows($rs); if($num>0){ //check if more than 0 record found echo "<table border='1'>"; echo "<tr>"; echo "<th>Product name</th>"; echo "<th>Product Tag Line</th>"; echo "<th>Product Price</th>"; echo "<th>Action</th>"; echo "</tr>"; //retrieve ocontents while($row=mysql_fetch_array($rs)){ extract($row); echo "<tr>"; echo "<td>{$product_name}</td>"; echo "<td>{$product_s_desc}</td>"; echo "<td>{$product_price}</td>"; echo "<td>"; echo "<a href='edit.php?id={$product_id}'>Edit</a>"; echo "</td>"; echo "</tr>"; } echo "</table>"; }else{ //if no records echo "No records found."; } ?> and my edit form (edit.php) <?php include 'config_open_db.php'; //check if an action was set isset($_POST['action']) ? $action=$_POST['action'] : $action=""; if($action=="edit"){ //update the record $sql="update jos_vm_product, jos_vm_product_price set product_name='{$_POST['product_name']}', product_s_desc='{$_POST['product_s_desc']}', product_price='{$_POST['product_price']}', product_weight={$_POST['product_weight']}' where product_id={$_POST['id']}"; if(mysql_query($sql)){ echo "<div>Record was edited.</div>"; }else{ die("SQL: ".$sql." >> ".mysql_error()); } } $id=$_REQUEST['product_id']; //the user id $sql="select * from jos_vm_product, jos_vm_product_price WHERE jos_vm_product.product_id AND jos_vm_product_price.product_id={$id}"; $rs=mysql_query($sql) or die("SQL: ".$sql." >> ".mysql_error()); $num=mysql_num_rows($rs); if($num>0){ $row=mysql_fetch_assoc($rs); extract($row); ?> <!--we have our html form here where new user information will be entered--> <form action='#' method='post' border='0'> <table> <tr> <td>Product Name</td> <td><input type='text' name='product_name' value='<?php echo $product_name; ?>' /></td> </tr> <tr> <td>Product Tag Line</td> <td><input type='text' name='product_s_desc' value='<?php echo $product_s_desc; ?>' /></td> </tr> <tr> <td>Product Price</td> <td><input type='text' name='product_price' value='<?php echo $product_price; ?>' /></td> </tr> <tr> <td>Product_weight</td> <td><input type='text' name='product_weight' value='<?php echo $product_weight; ?>' /></td> <tr> <td></td> <td> <!-- so that we could identify what record is to be updated --> <input type='hidden' name='id' value='<?php echo $id ?>' /> <!-- we will set the action to edit --> <input type='hidden' name='action' value='edit' /> <input type='submit' value='Edit' /> </td> </tr> </table> </form> <?php }else{ echo "<div>User with this id is not found.</div>"; } echo "<a href='update.php'>Back To List</a>"; ?> i also need to limit the results to 30 and add pages for next 30 results etc but am unsure how.... any help will be greatly appreciated..
  10. Hi all, Heres my problem.... i have created a script that will run a category tree on my webpage and am wanting to integrate it into an existing java menu call slashdot (sdmenu). I have no idea where to start so was looking for some assistance... DB Setup: Column----- Type------------- NULL Default id------------- int(11)------------ No ----------------------auto Increment - Primary Key name ------ Varchar(255)--- No parent_id --- int(11)------------ No ------0 catDescrip-- varchar(255)-- YES -----NULL catOrder --- varchar(255) - YES ---- NULL isActive ------int(11) ----------- NO ------1 My Code for the category tree is as follows: <?php function hasChild($parent_id) { $sql = "SELECT COUNT(*) as count FROM categories WHERE parent_id = '" . $parent_id . "'"; $qry = mysql_query($sql); $rs = mysql_fetch_array($qry); return $rs['count']; } function CategoryTree($list,$parent,$append) { $list = '<li>'.$parent['name'].'</li>'; if (hasChild($parent['id'])) // check if the id has a child { $append++; $list .= "<ul class='child child".$append."'>"; $sql = "SELECT * FROM categories WHERE parent_id = '" . $parent['id'] . "'"; $qry = mysql_query($sql); $child = mysql_fetch_array($qry); do{ $list .= CategoryTree($list,$child,$append); }while($child = mysql_fetch_array($qry)); $list .= "</ul>"; } return $list; } function CategoryList() { $list = ""; $sql = "SELECT * FROM categories WHERE (parent_id = 0 OR parent_id IS NULL)"; $qry = mysql_query($sql); $parent = mysql_fetch_array($qry); $mainlist = "<ul class='parent'>"; do{ $mainlist .= CategoryTree($list,$parent,$append = 0); }while($parent = mysql_fetch_array($qry)); $list .= "</ul>"; return $mainlist; } ?> and the code i am wanting to place it into is as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="sdmenu/sdmenu.css" /> <script type="text/javascript" src="sdmenu/sdmenu.js"> </script> <script type="text/javascript"> // <![CDATA[ var myMenu; window.onload = function() { myMenu = new SDMenu("my_menu"); myMenu.init(); }; // ]]> </script> </head> <body> <!--Navbar test---------------------> <div style="float: left" id="my_menu" class="sdmenu"> <div> <span>one</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> <div> <span>two</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> <div class="collapsed"> <span>three</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> <div> <span>four</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> </div> </body> </html> a preview of the menu can be seen here: http://www.iwdmachines.co.uk/sd/ attached are the files for SDMENU sdmenu.zip
  11. ok, so after a lot of reasearch i have found and compiled a script that does that i want, the problem now exists that i have no idea how to impliment it with my current javascript... the two files are below......... The Function: <?php function hasChild($parent_id) { $sql = "SELECT COUNT(*) as count FROM categories WHERE parent_id = '" . $parent_id . "'"; $qry = mysql_query($sql); $rs = mysql_fetch_array($qry); return $rs['count']; } function CategoryTree($list,$parent,$append) { $list = '<li>'.$parent['name'].'</li>'; if (hasChild($parent['id'])) // check if the id has a child { $append++; $list .= "<ul class='child child".$append."'>"; $sql = "SELECT * FROM categories WHERE parent_id = '" . $parent['id'] . "'"; $qry = mysql_query($sql); $child = mysql_fetch_array($qry); do{ $list .= CategoryTree($list,$child,$append); }while($child = mysql_fetch_array($qry)); $list .= "</ul>"; } return $list; } function CategoryList() { $list = ""; $sql = "SELECT * FROM categories WHERE (parent_id = 0 OR parent_id IS NULL)"; $qry = mysql_query($sql); $parent = mysql_fetch_array($qry); $mainlist = "<ul class='parent'>"; do{ $mainlist .= CategoryTree($list,$parent,$append = 0); }while($parent = mysql_fetch_array($qry)); $list .= "</ul>"; return $mainlist; } ?> and the page code (styles etc) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="sdmenu/sdmenu.css" /> <script type="text/javascript" src="sdmenu/sdmenu.js"> </script> <script type="text/javascript"> // <![CDATA[ var myMenu; window.onload = function() { myMenu = new SDMenu("my_menu"); myMenu.init(); }; // ]]> </script> </head> <body> <!--Navbar test---------------------> <div style="float: left" id="my_menu" class="sdmenu"> <div> <span>one </span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> <div> <span>two</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> <div class="collapsed"> <span>three</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> <div> <span>four</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> </div> </body> </html> Can anyone shed some light on this, i have always had issues with merging the two together and escaping etc....
  12. Hmm, thanks for that, im trying a few things but not getting the correct result, however i am not very compliant with recursive functions..... ill keep trying.....
  13. Hi all, Im hoping to get a little help or to be pointed in the right direction, what im trying to do is make a DB led category system that will pull data from a table and publish. hopefully looking something like this: -category1 -subcat1 -subcat2 -catrgory2 -subcat1 -subcat2 -category3 -category4 etc etc etc... my table is set up as so: Column Type NULL Default Comments id int(11) No auto Increment - Primary Key catName Varchar(255) No category Title parentCat int(11) No 0 Parent category ID for Sub Categories catDescrip varchar(255) YES NULL Text description of category catOrder varchar(255) YES NULL List Order of Categories isActive int(11) NO 1 Is Active = 1 Innactive = 0 my current page design for the category menu is this: <div style="float: left" id="my_menu" class="sdmenu"> <div> <span>Category 1</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> <div> <span>Category 2</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> <div class="collapsed"> <span>Category 3</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> <div> <span>Category 4</span> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> <a href="link1.php">link1</a> </div> </div> any help would be appreciated as i am unsure on how to begin with this.
  14. thanks I have included it in the conditionla statement now however it is still not echo-ing the current contents of the database according to the id as required, and for the life in me i cannot see why not
×
×
  • 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.