Jump to content

jacko_162

Members
  • Posts

    405
  • Joined

  • Last visited

Everything posted by jacko_162

  1. The Script works fine, i wanted to make the stars script work on multiple products, so i added "product_id" column to my database. i can pass a url such as index.php?ID=XX but i am not sure how to alter the above code to pull the id from URL, pass it through the script and eventually add the product_id to the database.
  2. I have 2 pages which is for a rating system with stars. index.php <!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>Ajax Rating System: Create Simple Ajax Rating System using jQuery AJAX and PHP : 99Points.Info</title> <script type="text/javascript" src="jquery-1.2.6.min.js"></script> <link href="99points.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> // <![CDATA[ $(document).ready(function(){ $('#loader').hide(); $('#inner').children().click(function(){ var a = $(this).attr("id"); $.post("rating.php?value="+a, { }, function(response){ $('#inner').fadeOut(); $('#inner').html(unescape(response)); $('#inner').fadeIn(); setTimeout("hideMesg();", 2000); }); }); }); function hideMesg(){ $('.rating_message').fadeOut(); $.post("rating.php?show=1", { }, function(response){ $('#inner').html(unescape(response)); $('#inner').fadeIn('slow'); }); } // ]]> </script> </head> <body> <?php include("dbcon.php"); $result=mysql_query("select sum(rating) as rating from ratings"); $row=mysql_fetch_array($result); $rating=$row['rating']; $product_id = $_get[iD]; $quer = mysql_query("select rating from ratings"); $all_result = mysql_fetch_assoc($quer); $rows_num = mysql_num_rows($quer); if($rows_num > 0){ $get_rating = floor($rating/$rows_num); $rem = 5 - $get_rating; } else { $rem = 5; }?> <h1>Ajax Test Rate System.</h1> <div align="center" style="margin:30px;"> <div id="container"> <img src="2.gif" alt="" height="300" /> <div id="outer"> <div id="inner"> <?php for($k=1;$k<=$get_rating;$k++){?> <div class="rating_enb" id="<?php echo $k?>"> </div> <?php }?> <?php for($i=$rem;$i>=1;$i--){?> <div class="rating_dis" id="<?php echo $k?>"> </div> <?php $k++; }?> <div class="rating_value"><?php echo ((@$get_rating) ? @$get_rating : '0')?>.0 (<?php echo $rows_num?>)</div> </div> </div> </div> </div> </body> </html> then the rating.php (does the functions) <?php include("dbcon.php"); //echo $_SERVER['REMOTE_ADDR'].'--' . $_REQUEST['value']; echo $_REQUEST['id']; $users_ip = $_SERVER['REMOTE_ADDR']; if($_REQUEST['value']) { $id = $_REQUEST['value']; $result = mysql_query("select users_ip from ratings where users_ip='$users_ip'"); $num = mysql_num_rows($result); if($num==0) { $query = "insert into ratings (rating,users_ip) values ('$id','$users_ip')"; mysql_query( $query); $result=mysql_query("select sum(rating) as rating from ratings"); $row=mysql_fetch_array($result); $rating=$row['rating']; $quer = mysql_query("select rating from ratings"); $all_result = mysql_fetch_assoc($quer); $rows_num = mysql_num_rows($quer); if($rows_num > 0){ $get_rating = floor($rating/$rows_num); $rem = 5 - $get_rating; } ?> <?php echo $_get['id']; ?> <?php for($k=1;$k<=$get_rating;$k++){?> <div class="rating_enb" id="<?php echo $k?>"> </div> <?php }?> <?php for($i=$rem;$i>=1;$i--){?> <div class="rating_dis" id="<?php echo $k?>"> </div> <?php $k++; }?> <div class="rating_value"><?php echo ((@$get_rating) ? @$get_rating : '0')?>.0 (<?php echo $rows_num?>)</div> <?php } else { echo '<div class="rating_message">You have already Voted for this product!!</div>'; } } if(@$_REQUEST['show']) // show rating again after showing message { $result=mysql_query("select sum(rating) as rating from ratings"); $row=mysql_fetch_array($result); $rating=$row['rating']; $quer = mysql_query("select rating from ratings"); $all_result = mysql_fetch_assoc($quer); $rows_num = mysql_num_rows($quer); if($rows_num > 0){ $get_rating = floor($rating/$rows_num); $rem = 5 - $get_rating; }?> <?php for($k=1;$k<=$get_rating;$k++){?> <div class="rating_enb" id="<?php echo $k?>"> </div> <?php }?> <?php for($i=$rem;$i>=1;$i--){?> <div class="rating_dis" id="<?php echo $k?>"> </div> <?php $k++; }?> <div class="rating_value"><?php echo ((@$get_rating) ? @$get_rating : '0')?>.0 (<?php echo $rows_num?>)</div> <?php }?> the script finds my ip address fine, and the value is forwarded and both added to my database. what i wanted to add onto this is an id number in the URL. namely "rating.php?ID=47" this is then going to be inserted into the db in the rating.php file. can someone help me code this please?
  3. aaah while loop was closing before i called line 43, fixed it now. =)
  4. ok for some reason i was getting 3x arrays so gone back with the original method. my current code is: <?php session_start(); include('Includes/auth.php'); require_once('header.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-style-type" content="text/css" /> <meta http-equiv="content-script-type" content="text/javascript" /> <title>Cpanel - Tag Product</title> </head> <body> <?php $sql2 = mysql_query("select * from tags WHERE tag='$tag'"); while ($data = mysql_fetch_array($sql2)) { $pid = $data["pid"].', '; echo $pid; } ?> <div id="container"> <div class="inner-container"> <div class="box box-100 altbox"> <div class="boxin"> <div class="header"> <h3>Related Products » Tag - <?php echo $tag; ?></h3> </div><div class="content"> <table cellspacing="0"> <thead> <tr> <td><strong>Image</strong></td> <th><strong>Product Name</strong></th> <td class="tc"><strong>Catagory</strong></td> <td class="tc"><strong>Sub Catagory</strong></td> <td class="tc"><strong>Price (£)</strong></td> <td class="tc"><strong>Images</strong></td> <td class="tc"><strong>Comments</strong></td> <td></td> <? // Query to pull information from the "products" Database $result = mysql_query("select * from $table1 WHERE id='$pid'"); while ($row = mysql_fetch_object($result)) { ?> </tr> </thead> <tbody> <tr class="first"> <th onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand"><a class="ico" href="product.php?ID=<?php echo $row->id; ?>"><img src="../images/products/<?php echo $row->id; ?>thumb.jpg" border="0" style="border: 1px solid #666666" width="35" height="35" /></a></th> <!-- .first for first row of the table (only if there is thead) --> <th onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand"><a class="ico" href="product.php?ID=<?php echo $row->id; ?>"><? echo $row->name; ?></a></th> <td class="tc" onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand"><? echo $row->catagory; ?></td> <td onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand"><? echo $row->subcatagory; ?></td> <td onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand">£<?echo $row->price;?></td> <td> <div align="center"> <?php // Check if Image one is available $filename = "../images/products/".$row->id."one.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image One' rel='fancy2' href='../images/products/".$row->id."one.jpg'>1</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."two.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Two' rel='fancy2' href='../images/products/".$row->id."two.jpg'>2</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."three.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Three' rel='fancy2' href='../images/products/".$row->id."three.jpg'>3</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."four.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Four' rel='fancy2' href='../images/products/".$row->id."four.jpg'>4</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."five.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Five' rel='fancy2' href='../images/products/".$row->id."five.jpg'>5</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."six.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Six' rel='fancy2' href='../images/products/".$row->id."six.jpg'>6</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."thumb.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Thumbnail' rel='fancy2' href='../images/products/".$row->id."thumb.jpg'>T</a>"; } else { echo ""; } ?> </div></td> <td><div align="center"> <a id="iframe2" class="ico-comms" href="viewcomments.php?ID=<?php echo $row->id; ?>"> <? // Query to pull information from the "coments" Database $ret = mysql_query("SELECT * FROM $table12 WHERE productid='$row->id' AND reply='yes'"); { echo mysql_num_rows($ret); mysql_free_result($ret); } ?> </a></div></td> <!-- a.ico-comms for comment-like backgrounds --> <td><a class="ico" id='tooltip' title='View This Item' href="product.php?ID=<?php echo $row->id; ?>"><img src="Includes/css/img/led-ico/blog.png" border="0" /></a> <a class="ico" id='tooltip' title='Edit This Item' href="edit.php?ID=<? echo $row->id; ?>"><img src="Includes/css/img/led-ico/pencil.png" border="0" /></a> <a class="ico" id='tooltip' title='Delete This Item' href="remove.php?ID=<? echo $row->id; ?>&db=products"><img src="Includes/css/img/led-ico/delete.png" border="0" /></a> <? } mysql_free_result($result); ?></td> </tr> </tbody> </table> </div> </div> </div> </div> <!-- .inner-container --> </div> </div> </body> when i run: echo $pid; i get: 42, 40, 47, how can i use this to modify the code on line 43; $result = mysql_query("select * from $table1 WHERE id='$pid'"); to pull information on all the above ID's instead of just the last one as its doing now.
  5. ok i changed it to put the PID into an array with the following code: $pid_array = array(); $sql2 = mysql_query("select * from tags WHERE tag='$tag'"); while ($data = mysql_fetch_array($sql2)) { $pid_array[] = $data["pid"]; print_r($pid_array); } after i print_r $pid_array i get the following: Array ( [0] => 42 ) Array ( [0] => 42 [1] => 40 ) Array ( [0] => 42 [1] => 40 [2] => 47 ) how can i modify my SQL $result = mysql_query("select * from $table1 WHERE id='$pid'"); to pull only information in the array for the "WHERE" clause?
  6. doesnt that just mean you havnt set the column to NULL by default?
  7. thank you, now when i eco $pid i get: 42, 40, 47, (it has the ending ',' does that matter?) now in my loop i have the sql statement: $result = mysql_query("select * from $table1 WHERE id='$pid'"); while ($row = mysql_fetch_object($result)) { this is only showing 1 row WHERE ID='47' how can i modify it to show all the above rows where ID=$pid ? such a headache with this, should be simple php =(
  8. I have a sql query that pulls data from URL then finds this data in a table. for example my URL is: product_tag.php?tag=product it then pulls a table and checks all results which contain the tag name product in the "name" column. if i run the following: echo $pid; i get all the data but grouped together. for example: 47484950 (should be 47, 48, 49,50) i then need to run a query to show all rows that contain the numbers above. confusing i know. here is my full page code. <?php session_start(); include('Includes/auth.php'); require_once('header.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-style-type" content="text/css" /> <meta http-equiv="content-script-type" content="text/javascript" /> <title>Cpanel - Tag Product</title> </head> <body> <?php if ($TAG) { $sql = "SELECT * FROM $table1 WHERE ID=$pid"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); $ID = $myrow["id"]; $name = $myrow["name"]; $make = $myrow["make"]; $price = $myrow["price"]; $catagory = $myrow["catagory"]; $subcatagory = $myrow["subcatagory"]; $description = $myrow["description"]; $Opt1 = $myrow["Opt1"]; $cotw = $myrow["cotw"]; $sold = $myrow["sold"]; $Opt2 = $myrow["Opt2"]; $Opt3 = $myrow["Opt3"]; $Opt4 = $myrow["Opt4"]; $Opt5 = $myrow["Opt5"]; $sold = $myrow["sold"]; } $sql2 = mysql_query("select * from tags WHERE tag='$tag'"); while ($data = mysql_fetch_array($sql2)) { $pid = $data["pid"]; //echo $pid; } ?> <div id="container"> <div class="inner-container"> <div class="box box-100 altbox"> <div class="boxin"> <div class="header"> <h3>Related Products » Tag - <?php echo $tag; ?></h3> </div><div class="content"> <table cellspacing="0"> <thead> <tr> <td><strong>Image</strong></td> <th><strong>Product Name</strong></th> <td class="tc"><strong>Catagory</strong></td> <td class="tc"><strong>Sub Catagory</strong></td> <td class="tc"><strong>Price (£)</strong></td> <td class="tc"><strong>Images</strong></td> <td class="tc"><strong>Comments</strong></td> <td></td> <? // Query to pull information from the "products" Database $result = mysql_query("select * from $table1 WHERE id='$pid'"); while ($row = mysql_fetch_object($result)) { ?> </tr> </thead> <tbody> <tr class="first"> <th onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand"><a class="ico" href="product.php?ID=<?php echo $row->id; ?>"><img src="../images/products/<?php echo $row->id; ?>thumb.jpg" border="0" style="border: 1px solid #666666" width="35" height="35" /></a></th> <!-- .first for first row of the table (only if there is thead) --> <th onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand"><a class="ico" href="product.php?ID=<?php echo $row->id; ?>"><? echo $row->name; ?></a></th> <td class="tc" onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand"><? echo $row->catagory; ?></td> <td onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand"><? echo $row->subcatagory; ?></td> <td onClick="document.location.href='product.php?ID=<?php echo $row->id; ?>';" style="cursor:pointer;cursor:hand">£<?echo $row->price;?></td> <td> <div align="center"> <?php // Check if Image one is available $filename = "../images/products/".$row->id."one.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image One' rel='fancy2' href='../images/products/".$row->id."one.jpg'>1</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."two.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Two' rel='fancy2' href='../images/products/".$row->id."two.jpg'>2</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."three.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Three' rel='fancy2' href='../images/products/".$row->id."three.jpg'>3</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."four.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Four' rel='fancy2' href='../images/products/".$row->id."four.jpg'>4</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."five.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Five' rel='fancy2' href='../images/products/".$row->id."five.jpg'>5</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."six.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Image Six' rel='fancy2' href='../images/products/".$row->id."six.jpg'>6</a>"; } else { echo ""; } ?> <?php // Check if Image one is available $filename = "../images/products/".$row->id."thumb.jpg"; if (file_exists($filename)) { echo "<a class='ico' id='fancybox' title='$row->name - Thumbnail' rel='fancy2' href='../images/products/".$row->id."thumb.jpg'>T</a>"; } else { echo ""; } ?> </div></td> <td><div align="center"> <a id="iframe2" class="ico-comms" href="viewcomments.php?ID=<?php echo $row->id; ?>"> <? // Query to pull information from the "coments" Database $ret = mysql_query("SELECT * FROM $table12 WHERE productid='$row->id' AND reply='yes'"); { echo mysql_num_rows($ret); mysql_free_result($ret); } ?> </a></div></td> <!-- a.ico-comms for comment-like backgrounds --> <td><a class="ico" id='tooltip' title='View This Item' href="product.php?ID=<?php echo $row->id; ?>"><img src="Includes/css/img/led-ico/blog.png" border="0" /></a> <a class="ico" id='tooltip' title='Edit This Item' href="edit.php?ID=<? echo $row->id; ?>"><img src="Includes/css/img/led-ico/pencil.png" border="0" /></a> <a class="ico" id='tooltip' title='Delete This Item' href="remove.php?ID=<? echo $row->id; ?>&db=products"><img src="Includes/css/img/led-ico/delete.png" border="0" /></a> <? } mysql_free_result($result); ?></td> </tr> </tbody> </table> </div> </div> </div> </div> <!-- .inner-container --> </div> </div> </body> apologies for the messy code, im still learning.
  9. OK in a previous post i discussed how i would go about adding product tags to my CMS system, This has now been coded and implimented by myself, the ability to add, view and delete is now done. i have a tag list page, which lists the tags like so: A ------ "Tag Name" "Tag Name" "Tag Name" "Tag Name" B ------ "Tag Name" "Tag Name" "Tag Name" etc. the above is coded using: <?php $qry = "SELECT tag, LEFT(tag, 1) AS first_char FROM tags WHERE UPPER(LEFT(tag, 1)) BETWEEN 'A' AND 'Z' OR LEFT(tag, 1) BETWEEN '0' AND '9' ORDER BY tag"; $result = mysql_query($qry); $current_char = ''; while ($row = mysql_fetch_assoc($result)) { if ($row['first_char'] != $current_char) { $current_char = $row['first_char']; echo '<br /><br /><span class="bigtag">' . strtoupper($current_char) . '</span><br />---------------<br />'; } $tagname = $row['tag']; echo "<div class='tag tag-left'>"; echo "<div class='left'></div>"; echo "<div class='center'><a href='product_tag.php?tag=$tagname'>"; echo $row['tag'] . ''; echo "</a></div>"; echo "<div class='right'></div></div>"; } ?> now problem i have is sometimes tags are duplicated, for instance atm i have the colour "Red" tagged 5 times, and it appears 5 times under the "R" column using above layouts. R ------ "Red" "Red" "Red" "Red" "Red" How can i limit it to show only the once please?
  10. I have a post tag image which is a set width, how can i use this image with css to have differnt widths using the same image? i have attached what the tag looks like with different sized text. any help on the matter would be appreciated. this is my first FULL .css managed site and i get so confused. [attachment deleted by admin]
  11. OK manually added some tags in a db table as follows: 3x colums "id" "pid" "tag" id = auto_increment and primary key, pid is equal to the product ID and tag is obviosuly the tag. i use the following query to fetch data randomly; // Query to randomly select multiple tags for this product $sqltag = mysql_query("SELECT `tag` FROM tags WHERE `pid`=47 ORDER BY RAND() LIMIT 0,8"); $rowtag = mysql_fetch_array($sqltag); how do i echo the multiple results? if i use; <? echo $rowtag['tag']; ?> i just get the 1 random result returned instead of the 8? help please
  12. i was thinking this way, dont i need a 3rd column for id and hae it primary key?
  13. I have coded a small CMS script which allows me to add products to a sort of "online" catalogue. what i want to do is allow myself and others with access to be able to edit a product and add "tags" for instance if i had a yellow product i would add the tag "yellow" then eventully i will use the built in search function to search for specific tags, and also allow users to click on tags in a sort of tag cloud to browse for anything with the same or popular tags. How would i go about this? would i store the tags in an array for each product in the products table?? for instance; TAGS: "yellow, big, bright, popular, special" if i store them in the above format, how would i randomly show a list of 10 tags from multiple products on my homepage or even better the top 10 most common tags? any help, pointers or source code to work from would be awsomly appreciated, as im still learning PHP and reading code and figuring it out is the best way im learning.
  14. this is similar idea to what i wanted to do. i plan to release updates initially every few weeks, how would i go about having each script to hold a version number in the sql db, upon loading an "update.php" page i want it to check the "latest version" from my server and compare it to the local version and if its lower then show a message etc..
  15. OK i have coded a half decent CMS system that i will resell. problem i will have is each person will have different database and probably a different host to my own. if for example i wanted to post a "news" item to all the CMS dashboards how would i go about doing this in the code logistically? only way of doing something like this i can see is hard coding a frame to a PHP file located on my servers? and anyone have any name suggestions for my CMS script, mainly aimed at local automotive and estate agents?
  16. you only allow .jpg etc; $allowed_filetypes = array('.jpg','.gif','.bmp','.png'); ?
  17. tbh before coding i wanted to sort out the logic behind it all, admin creates an "album" then name this album, this is then input into db with a timestamp, ID, and the name. user can then click this album in the admin control panel, from here he will see an upload script (about 5 upload boxes shown) the admin can then select the images to upload and click submit. Upon submit i wanted a small code to say fetch album name, once fetched check if upload dir has a folder called "albumname" if it has upload to there, if not create dir, and uplaod there. this doable? if so i will start on creating the upload code
  18. I have a PHP coded page that uploads images fine to my server. What i wanted to know is on the page i have a <SELECT> form that allows the user to select a "album" name, is it possible to use this to create a subfolder in the upload directory using that name? so the user selects "misc" album, thjen uploads 5 images. when submit is entered it checks to see if there is a "misc" folder, if not creates one and uploads the 5x files into that new or currently existing folder. Can this be done, and if so can anyone help me to do so?
  19. figured it out already as i clicked submit on this post. if (isset($submit)) { should be: if (isset($_POST['submit'])) {
  20. I have the below code: <div> <table width="100%" border="0" cellspacing="0" cellpadding="4"> <tr> <td colspan="7" valign="top"> <form enctype="multipart/form-data" action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <?php if (isset($submit)) { // UPDATE QUERY CODE WHEN SUBMIT IS ENTERED $str = implode(';',$_POST['checks']); $insert = "UPDATE members SET settings='$str' WHERE member_id='$_SESSION[sESS_MEMBER_ID]'"; if (@mysql_query($insert)) { ?> <script type="text/javascript"> document.location.replace('settings-tests.php'); </script> <?php } else { echo('Error in you submission:' . mysql_error() . "<br /><br />" . $sql); } } ?> <?php { $result=mysql_query("SELECT * FROM members WHERE member_id = '$_SESSION[sESS_MEMBER_ID]'"); $row = mysql_fetch_array($result); $arr = array(); $arr = explode(';',$row['settings']); $member_id = $row['member_id']; $firstname = $row['firstname']; $lastname = $row['lastname']; $email = $row['email']; $membership = $row['membership']; $roles = $row['roles']; $login = $row['login']; ?> <table width="100%" border="0" cellspacing="0" cellpadding="4"> <tr> <td colspan="2"><h3>Test Results Settings</h3></td> <td width="25%"> </td> <td width="25%"><?php echo $_SESSION['SESS_MEMBER_ID']; ?></td> </tr> <tr> <td colspan="4"><em>To turn off individual results gloablly across the site please use the following sliders (all results already added will also be made invisable)<br /> <br /> </em></td> </tr> <tr> <td width="25%"><div align='right'><strong><em>Salinity:</em></strong></div></td> <td width="25%"><input type="checkbox" value="test1" name="checks[]2" <?php echo (in_array("test1",$arr) ? "checked" : ''); ?>/></td> <td><div align='right'><strong><em>Phosphate:</em></strong></div></td> <td><input type="checkbox" value="test9" name="checks[]10" <?php echo (in_array("test9",$arr) ? "checked" : ''); ?>/></td> </tr> <tr> <td><div align='right'><strong><em>PH:</em></strong></div></td> <td><input type="checkbox" value="test2" name="checks[]3" <?php echo (in_array("test2",$arr) ? "checked" : ''); ?>/></td> <td><div align='right'><strong><em>potassium:</em></strong></div></td> <td><input type="checkbox" value="test10" name="checks[]11" <?php echo (in_array("test10",$arr) ? "checked" : ''); ?>/></td> </tr> <tr> <td><div align='right'><strong><em>Ammonia:</em></strong></div></td> <td><input type="checkbox" value="test3" name="checks[]4" <?php echo (in_array("test3",$arr) ? "checked" : ''); ?>/></td> <td><div align='right'><strong><em>Iodine:</em></strong></div></td> <td><input type="checkbox" value="test11" name="checks[]12" <?php echo (in_array("test11",$arr) ? "checked" : ''); ?>/></td> </tr> <tr> <td><div align='right'><strong><em>Nitrite:</em></strong></div></td> <td><input type="checkbox" value="test4" name="checks[]5" <?php echo (in_array("test4",$arr) ? "checked" : ''); ?>/></td> <td><div align='right'><strong><em>Strontium:</em></strong></div></td> <td><input type="checkbox" value="test12" name="checks[]13" <?php echo (in_array("test12",$arr) ? "checked" : ''); ?>/></td> </tr> <tr> <td><div align='right'><strong><em>Nitrate:</em></strong></div></td> <td><input type="checkbox" value="test5" name="checks[]6" <?php echo (in_array("test5",$arr) ? "checked" : ''); ?>/></td> <td><div align='right'><strong><em>Silica:</em></strong></div></td> <td><input type="checkbox" value="test13" name="checks[]14" <?php echo (in_array("test13",$arr) ? "checked" : ''); ?>/></td> </tr> <tr> <td><div align='right'><strong><em>Calcium:</em></strong></div></td> <td><input type="checkbox" value="test6" name="checks[]7" <?php echo (in_array("test6",$arr) ? "checked" : ''); ?>/></td> <td><div align='right'><strong><em>Temperature:</em></strong></div></td> <td><input type="checkbox" value="test14" name="checks[]" <?php echo (in_array("test14",$arr) ? "checked" : ''); ?>/></td> </tr> <tr> <td><div align='right'><strong><em>Magnesium:</em></strong></div></td> <td><input type="checkbox" value="test7" name="checks[]8" <?php echo (in_array("test7",$arr) ? "checked" : ''); ?>/></td> <td></td> <td></td> </tr> <tr> <td><div align='right'><strong><em>Alkalinity:</em></strong></div></td> <td><input type="checkbox" value="test8" name="checks[]9" <?php echo (in_array("test8",$arr) ? "checked" : ''); ?>/></td> <td colspan="2" align="right"></td> </tr> <tr> <td colspan="4" align="right"><table border="0" cellspacing="0" cellpadding="8"> <tr> <td><input class="Button" type="submit" name="submit" value="Submit" /></td> <td><input class="Button-alt" type="reset" name="reset" value="Reset" /></td> </tr> </table></td> </tr> </table> <br /> </form><?php } ?> </td> </tr> </table> </p> </div> This pulls data in array from database for example: test1;test9;test2;test3;test4;test5;test6;test14;test7;test8 The SELECT query works fine if i manually edit the array in the database to make the boxes checked or not. Problem seems to be when i click submit, its not updating the DATABASE?! i recently upgraded to PHP5 eventually and it seems it stopped working arond then. any help please.
  21. For instance if i set the following 2x variables; "$varOne = $_GET[first_name]" "$varTwo = $_GET[last_name]" "$varThree = $_GET[userid]" how do i insert them both together into a DB field for example: $full = $varOne,$varTwo,$varThree (without the , ) this would then be echo as : joebloggs66985 i have the INSERT in there atm but i wanted to insert first name and last name together with there userid to generate a sort of username possibility. sorry if i didnt explain correcly
  22. well i managed to print_r the array and found out it shoul be array[79] =) problem solved.. thanks for help guys as usuall. *thumbs up*
×
×
  • 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.