PHP - Problem Select From Database
Hello everybody,
I have a problem selecting rows from db. Copied error message: Quote Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\scriptforsite\index.php on line 223 I have searched for this problem, and I found tons of posts but I didn't do anything. Here is a code: Code: [Select] <?php include("include/functions.php"); db_connect(); lang_en(); lang_smiles(); lang_links(); $sql= mysql_query("SELECT msg_id,msg from messages order by msg_id desc"); while($row=mysql_fetch_array($sql)) { $msg=$row['msg']; $msg_id=$row['msg_id']; ?> <li class="bar<?php echo $msg_id; ?>"> <div align="left"> <span ><?php echo $msg; ?> </span> <span class="delete_button"><a href="#" id="<?php echo $msg_id; ?>" class="delete_update">X</a></span> </div> </li> <?php } db_close(); ?> This line 223 is this: $sql= mysql_query("SELECT msg_id,msg from messages order by msg_id desc"); ... I have tried to replace msg_id,msg with * but on this way I don't have dump from table... Similar Tutorialshirealimo.com.au/code1.php this works as i want it: Quote SELECT * FROM price INNER JOIN vehicle USING (vehicleID) WHERE vehicle.passengers >= 1 AND price.townID = 1 AND price.eventID = 1 but apparelty selecting * is not a good thing???? but if I do this: Quote SELECT priceID, price FROM price INNER JOIN vehicle....etc it works but i lose the info from the vehicle table. but how do i make this work: Quote SELECT priceID, price, type, description, passengers FROM price INNER JOIN vehicle....etc so that i am specifiying which colums from which tables to query?? thanks Hi guys, it's me Captain Failure, back with more antics. I can't get this to link to the database and was wondering if anyone could help :/ The main code is the second block below but I have posted some of the config file also. Config.php public $db_host = 'localhost'; public $db_user = 'user'; public $db_pass = 'pass'; public $db_name = 'db'; Main page require_once('config.php'); $c = new Config; $query = "DELETE FROM tsclient WHERE id = '".$uid."';"; $db_connection = mysql_connect($c->db_host,$c->db_user,$c->db_pass); if (!$db_connection) { die($errmsg['ERR_MYSQL']); } $db_selection = mysql_select_db($c->db_name,$db_connection); if (!$db_selected) { die($l->errmsg['ERR_DBFAIL']); } mysql_query($query,$db_selection); mysql_close($db_connection); I keep hitting die($l->errmsg['ERR_DBFAIL']); but can't work out why... The use has All Privileges in that database and the user/pass details must be correct because it is actually connecting and not giving out [ph]die($errmsg['ERR_MYSQL']);[/php] Can anyone help? :/ Hello everyone and thank you for taking the time to read this. I am very new to coding and I am helping a friend with a website. I'm trying to create a form with a <select> dropdown and filling the options with items from a database, there are very man items so I'm not sure 100% how to go about this, I have some code but I know it's wrong I'm just looking for a nudge in the right direction, any help is appreciated the code can be found below: Code: [Select] <div style="float:left;"> <select> $team = $sql->query("SELECT * FROM teams WHERE arenaid ='$platid'"); <option value="<?echo $teams>"></option> </select> </div> Again, thank you for taking the time to read this and thank you also for any help you can provide. I create list box which value contains from the table of database but now i want to display the data related to the value of list box. please any body can help me to solve the problem My table contains id, category_name, title, discription and list box contain the value from the filed category_name of the table now i want to display title and discription according to the category_name. please send me code i am totally confused.. Hi guys, is it possible to update a field ina a database using a select box. So far i have populated the select box with database values and it works fine, however i dont know how to update the field properly in a database. have a look at the code and tell me what you think. Code: [Select] <?php session_start(); ?> <!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>stock manager</title> </head> <body> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stockname" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stockqty" type="text" /> </td> </tr> </table> <input name="submit1" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockview.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> <BR /><BR /> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT stockname, stockqty FROM stocks"); $result = mysql_query ($query); echo "<table border='1'>"; echo "<tr><th>Stock Name</th> <th>Stock Quantity</th></tr>"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr><td>"; echo $row['stockname']; echo "</td>"; echo "<td>"; echo $row['stockqty']; echo "</td>"; } ?> </center> <table> <tr> <td> </td> <td> </td> </tr> </body> </html> Here is the page that handles the form Code: [Select] <?php session_start(); $_SESSION['nt']; $sn = $_SESSION['nt']; ?> <!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>stock</title> </head> <body> <?php $submit1 =&$_POST['submit1']; $stockname =&$_POST['stockname']; $stockqty =&$_POST['stockqty']; $submit = &$_POST['submit']; $stockqty1 = &$_POST['stock_qty1']; if(isset($submit1)) { if(isset($stockname) && ($stockqty)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query = mysql_query("SELECT * FROM stocks WHERE stockname='$stockname'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo("Item already exists!");?><BR /><BR /><?php echo("Please Add A non-existent Item!");?> <a href="stockmanager.php">Try again!</a><?php } else { $queryreg = mysql_query("INSERT INTO `stocks` (stockname, stockqty) VALUES ('$stockname','$stockqty')"); echo("Stock has been added"); ?><BR /><BR /> <?php echo("Click here to return to stock manager!");?> <a href="stockmanager.php">Click Here!</a><?php } } else { echo("Please fill in all fields to add stock!"); } } if(isset($submit)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty1'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty=$stockqty1 WHERE stockname=$sn'"); echo("Item has been updated"); } ?> </body> </html> Any help woul;d be really great, i ahve tried everything for days on end now Thanks Lance Ok, so I am trying to make a database with PHP and I hit a snag. First off, here is the code in question. Code: [Select] <?php //GET CONFIG include_once('../scripts/config.inc.php'); //SET VARIABLES TO SOMETHING A BIT SHORTER FOR THE DATABASE OPTIONS $host = $config['db_settings']['db_host']; $user = $config['db_settings']['db_user']; $pass = $config['db_settings']['db_pass']; $prefix = $config['db_settings']['db_prefix']; $db = $config['db_settings']['db_name']; $con = mysql_connect($host, $user, $pass); $select_db = mysql_select_db($db); $c_tables = ''; $c_database = "CREATE DATABASE IF NOT EXISTS $db;"; //NOW CONNECT TO THE SERVER if ($con){ echo('Connected Succesfully to the Server <br />'); } else die('Could not connect to database: ' . mysql_error()); //NOW CONNECT TO THE DATABASE if ($select_db){ echo('Selected Database Succesfully <br />'); } //IF DATABASE COULD NOT BE SELECTED THEN TRY TO MAKE IT else if(!$select_db){ echo('Could not select the databse. Trying to create it... <br />'); if(mysql_query($c_database)){ echo('Database has been created...<br />'); if($select_db){ echo('Database Has Been Selected.'); } else die('Can not select database!' . mysql_error()); } else die('Could not created the database!'); } else die ('Could not create or select the database!: ' . mysql_error() . '<br />'); //NOW CREATE THE TABLES mysql_close; ?>The problem is, that if I drop the database to test that it creates the database, it does indeed make it, but after it makes the database it will not select it until I reload the page and intern the script. So this is the output I would get. (The fact that there is no error is what is causing me to be confused) 1st load that makes new database: Quote Connected Succesfully to the Server Could not select the databse. Trying to create it... Database has been created... Can not select database! 2nd load that should not be needed to select the database: Quote Connected Succesfully to the Server Selected Database Succesfully Hi guys, Im developing a stock system and so far new stock and can be added with the quantity, however im trying to update the stock by using a select box and selecting the type of stock and inputting a new qty. the form and everything is set up and i can select files from the database, however i dont know how to update files from a select box The code i got so far is Code: [Select] <!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>stock manager</title> </head> <body> <?php $stockqty =&$_POST['stock_qty1']; ?> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stock_name" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockmanager.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty='$stockqty' WHERE stockname = '$stockname'"); echo("Its updated"); ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> </center> </body> </html> Any help would be greatly appreciated. Thanks Lance This has been bugging me for quite a while and I've tried so many different things and just run into all kinds of problems... What I'm doing or trying at least is pulling data from a table displaying it into a multiple select box allowing the user the oppertunity to remove one or more options. As the code stands now I'm getting no value at all in the post variable, by taking the [] brackets out of the inputs name i was able to get the first selected option but the php code was then unable to remove that value from the database. I hope I'm explaining this well enough but the code follows I'd really appreciate some help or direction on this one. The FORM Code: [Select] <FORM action='' method='post'> <select size='8' multiple name='remove_player[]'> <?php foreach ($members as $key => $mem) { if ($mem != "") { $mem = str_replace("-", " ", $mem); $mem = ucwords($mem); echo ("<option value='" . $mem . "'>" . $mem . "</option>"); } } ?> </select> and then the handler code: Code: [Select] $to_remove = $_POST['remove_player']; $as_team = str_replace(" ", "-", $teamname); $as_team = strtolower($as_team); $for_remove = "SELECT * FROM teams WHERE name = '$as_team'"; $for_query = (mysql_query($for_remove)); foreach ($to_remove as $y => $z) { $z = str_replace(" ", "-", $z); $z = strtolower($z); } while($arr_remove = mysql_fetch_array($for_query)) { foreach ($arr_remove as $a => $b) { foreach ($to_remove as $c => $d) { if ($b == $d) { unset($arr_remove[$a]); } } } foreach ($arr_remove as $e => $f) { $add_replace = (mysql_result($for_query, 0, 'members')); $replace = ($add_replace . "\r\n" . $f . "\r\n"); $replace_mem = "UPDATE teams SET members = '$replace'"; $replace_q = (mysql_query($replace_mem)); } } echo "Member List successfully updated.<br>"; foreach ($to_remove as $h => $g) { echo ($g . " removed from the team.<br>"); } Also any time i try to print any part of the array/s I get no values but the database is being updated with 2 line breaks and a "3" at the end of the table which has me a bit confused as well. Thanks! Last Christmas my wife bought me a book on html and css because I said that I have always wanted to write a website. Over the last 10 months I have really enjoyed learning web design and have progressed to try and learn php and using myPHPadmin databases.
I am now trying to write a private message function. I've got a members database and a conversation database. I am trying to filter out whether a private message is 'read' or 'unread', but whatever I try it is still listing all messages under both options. I've spent 48 hours staring at this bit of code. Can anyone see what I have done wrong? The relevant (and self-explanatory) fields from my members database a id username member_first_name member_last_name The relevant fields from my conversation database a id id2 (always set as '1' to count messages in a conversation) member1 (the initial sender of the first message) member2 (the initial recipient of the first message) read1 (member1 has read this message default to yes when message sent and to no when message received) read2 (member2 has read this message default to yes when message sent and to no when message received) removed1 (member1 has deleted this message from their record) removed2 (member2 has deleted this message from their record) time (timestamp) <?php $query1 = DB::getInstance()->query("SELECT c1.id, c1.title, c1.time, c1.removed1, c1.removed2, count(c2.id) AS reps, m.id as memberid, m.username m.member_first_name, m.member_last_name FROM conversation as c1, conversation as c2, members as m WHERE ((c1.member1='{$logid}' AND c1.read1='No' AND c1.removed1='No' AND m.id=c1.member2) OR (c1.member2='{$logid}' AND c1.read2='No' AND c1.removed2='No' AND m.id=c1.member1)) AND c1.id2='1' AND c2.id=c1.id GROUP BY c1.id ORDER BY c1.id DESC"); $query2 = DB::getInstance()->query("SELECT c1.id, c1.title, c1.time, c1.removed1, c1.removed2, count(c2.id) as reps, m.id as memberid, m.username, m.member_first_name, m.member_last_name FROM conversation as c1, conversation as c2, members as m WHERE ((c1.member1='{$logid}' AND c1.read1='Yes' AND c1.removed1='No' AND m.id=c1.member2) OR (c1.member2='{$logid}' AND c1.read2='Yes' AND c1.removed2='No' AND m.id=c1.member1)) AND c1.id2='1' AND c2.id=c1.id GROUP BY c1.id ORDER BY c1.id DESC"); ?> UNREAD MESSAGES (<?php echo intval($query1->count()); ?>) <br> READ MESSAGES (<?php echo intval($query2->count()); ?>)I've tried running through things in a logical path: UNREAD MESSAGES member1 = logged in user read1 = No removed1 = No members.id = member2 OR member2 = logged in user read2 = No removed2 = No members.id = member1 READ MESSAGES member1 = logged in user read1 = Yes removed1 = No members.id = member2 OR member2 = logged in user read2 = Yes removed2 = No members.id = member1 I can't understand how if 'read1 = yes and the logged in user is member1, why they are being counted in the unread list. Can anyone see what I have done wrong? Edited by MartynLearnsPHP, 15 November 2014 - 08:05 AM. I have a simple database table that has the names of countries listed with just 2 fields ID & country.
I want to use this in a form to choose the country and provide statistics regarding that country.
I know how to get the data from MySQL, but I don't know how I can use this in the form as a selection?
How do I get the options to iterate all of the countries so that when the form is displayed a combo type box is displayed with a dropdown list?
I have not shown any code as I am not sure if this is possible.
Please can anyone advise if this is possible and if so some example code?
Hey guys, I am having trouble figuring this out. I currently have a database that automatically sorts itself by the id of the data. But, I am wanting the user to be able to change the sort order via a select box. I already have the select box programmed with the options, but I am not sure how to go about coding the options to change the sort order of the displayed data. What would the best way to go about programming this be? Thank you very much ahead of time!! Not sure why this isnt working. Code: [Select] <?php session_start(); ?> <!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> <script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script> <script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <LINK REL=StyleSheet HREF="inc/dyn_style.css" TYPE="text/css" MEDIA=screen /> <?php ?> <?php include('logic.inc'); mysqlConnect(); ?> <script type="text/javascript" src="bbeditor/ed.js"></script> <link rel="stylesheet" type="text/css" href="dyn_style.css" /> <title> Social </title> <script type="text/javascript"> function changeTitle(title) { document.title = title; } </script> </head> <body> <?php $inc = 'new_story.php'; $view = 'Newest '; $by = 'added'; $where = " "; $where2 = " "; $order = "ASC"; $gen = "All"; $rat = 'All'; $blerg = ""; $sort = 'newest'; //---------------------------------------------------------------------- if(isset($_GET['sub'])) { $sort = $_GET['sort']; switch($sort) { case "Most Popular"; $by = 'views'; $view = 'Most Popular '; $order = 'DESC'; break; case "Most Reviewed"; $view= 'Most Reviewed '; $by = 'reviews'; $order = 'DESC'; break; case "Newest"; $by = 'added'; $view = 'Newest'; $order = 'ASC'; break; } $genre = mysql_real_escape_string($_GET['cat']); $rating = mysql_real_escape_string($_GET['rat']); if($gen == 'All') { $where = " "; $blerg = ""; } else { $where = "WHERE cat='$gen'"; } if ($rat == "All") { $where2 = ' '; $blerg = 'AND'; } else { $where2 = $blerg ." rating = '$rat' "; } } //---------------------------------------------------------------------- ?> <?php serch(); ?> <form action="story.php" method="get"> <label id='inline'> Order By: </label> <select name='sort'> <option selected='yes' label='Currently Selected' > <?php echo $view; ?> </option> <option> Newest </option> <option> Most Popular</option> <option> Most Reviewed </option> </select> <input type='hidden' value='spec_view' name='p' /> <label id='inline'> Genre/Catagory: </label> <select name='gen'> <option selected='yes' label = 'Selected Genre - <?php echo $gen; ?>'> <?php echo $gen; ?> </option> <option> All </option> <option> Fantasy </option> <option> Adventure </option> <option> Science Fiction</option> <option> Drama</option> <option> Fable </option> <option> Horror</option> <option> Humor</option> <option> Realistic Fiction </option> <option> Tall Tale</option> <option> Mystery </option> <option> Mythology </option> <option> Poetry </option> <option> Shorty Story </option> <option> Romance </option> </select> <label id='inline'> Rating: </label> <select name='rat'> <option selected='yes' label = "Selected Genre - <?php echo $rat; ?>"> <?php echo $gen; ?> </option> <option> All </option> <option> C </option> <option> C13 </option> <option> YA </option> <option> A </option> </select> <input type='submit' value='Go!' name = 'go' /> </form> <?php $query = " SELECT * FROM story_info ORDER BY $by $order $where $where2 "; echo $query; $select = mysql_query($query) or die(mysql_error()); while($rows = mysql_fetch_assoc($select)) { $viewsdb = $rows['views']; $titledb = $rows['title']; $userdb = $rows['user']; $catdb = $rows['cat']; $ratdb = $rows['rating']; $id_db = $rows['story_id']; $sumdb = shorten($rows['sum']); echo "<h3><a href='?p=page&id=$id_db'> $titledb </a> </h3>"; echo "<div id='fun_info'>"; echo "$sumdb <br />"; echo "By <a href='?p=profile&user=$userdb'> $userdb </a> <br /> "; echo "$viewsdb Views | Rated: $ratdb | Catagory: <a href='?p=cat_view&gen=$catdb'> $catdb </a> </div>"; } ?> </div> </body> </html> could anyone please help me with the code which is i have already displayed data as a multi select list but now i need to select one or more from them and insert into another database table. would be appreciate your help. thanx Or something like that... I am not sure how to put this.. Anyway, I'll just get started with explaining my problem. I have an admin-page in which you can delete the comments given on blogs, using checkboxes and clicking on a button with the value 'verwijderenSubmit'. The deletion part works just fine, nothing wrong. However, I also want to be able to EDIT the comments with an other button called 'bewerkenSubmit', using the same checkboxes that I use for deletion. Selecting the right CID (CommentID) is no problem, because that works the same as the deletion-part, but selecting the right textarea to update into the database is the problem... I uploaded a file here with the whole code: http://dhost.info/ddfs/myproblem.html I escaped the textarea within with square brackets, because otherwise the whole textarea would screw up.. I also added <!-- RELEVANT CODE --> to select the parts that I need to change. Well, I hope you understand my problem and can help. Hi, I had a form which contains, 8 select boxes. In those 8 select boxes, 3 of the boxes are interlinked, like, I am able to generate data in other 2 select boxes, if one box is been selected. i.e. based upon selection of one select box, and i am able to generate data in other select box. So, 3 select boxes are interlinked. And remaining 5 selects are optional, if the user selects, then we need to generate data based upon selection of the user. Here the main issue is how to grab data in the post back form, like, how to capture the number of selects boxes selected and what are those selected, and based upon that we need to generate data. Here one more important thing is that, in the report generation form(postback form), I need to show the data in a table. So , in table I had 9 columns and these would be common to whatever the selection made, but, only the requeired data would be changed based upon the selection of the remaining 5 optional boxes. Hope you got me!!!! Hi. Maybe a tricky question? How do I reflect the content of a column from a database table in a roll down select menu in the browser? Let's say that the content of the table column is: Anna Michael These names should be reflected in this select menu like this: <select name="friends"> <option value="Choose a name">Choose a name</option> <option value="Anna">Anna</option> <option value="Michael">Michael</option> So visitors can choose a name, and thereby turn it into a variable, for reuse in the database. Best regards Morris I am currently creating a form and I want to populate a drop down selection menu with data from two fields in a form. For example, I want it to pull the first and last name fields from a database to populate names in a drop down menu in a form. I want the form to submit to the email address of the person selected in the drop down. Is this possible to do? The email is already a field in the record of the person in the database. Can anyone give me some pointers or advice on how I should go about setting up the "Select" box drop down? I am not sure how to code it to do what I am wanting. Any links to relevant help would be appreciated too. Thanks in advance! i need help with this issue.i designed a comment page where people can comment on a topic but what i descovered is that once i comment on a topic it will be showed on the page i asked it to go but if i comment on thesame topic it will not show exceeptb the one that as been there before.even if i click on anotherr topic and i comment once i cannot comment again but if i remove the WHERE clause all the comments meant for other topics will just display which is not good.Please help me thanks. this is my code: Code: [Select] <?php include"header.php"; $topicid=$_GET['id']; ///the two tables POST and TOPICS share thesame id $sql="SELECT post_comments FROM post WHERE $topicid=topicsID"; $result=mysql_query($sql) or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"{$row['post_comments']}"; } ?> I have a series of steps a user goes through to add a product. I'm having a problem with the first going to second page. The first page is a form to input information which has a "add" php file that goes with it that basically Posts and Inserts the information into the table, then moves on to the next page. It also auto increments a new id for the product in the table during this process. The problem is I'm trying to get the product id to carry over to the next page so they can review the information they just input. Any ideas on how I can pull that new id by going from that one page to the next with that move (Form>Insert(form action)>EditPage)? I'm just having a hard time visualizing this because I'm inserting the new product then there's nothing to reference because I can't pinpoint on the id yet. |