
SocomNegotiator
Members-
Posts
106 -
Joined
-
Last visited
Never
Everything posted by SocomNegotiator
-
Ok well right now my database is setup so that the user adds a single item to a pre_order table to their "cart" one by one. So each item has a different id. Now when they go to "checkout" I made it so that the info in the pre-order table gets transfered to the order table and then the info in the pre-order table for that user gets deleted. Well each user may have multiple orders. One order may have 4 items while another will have 10 items. Each item will have a different id even though when the order was purchased it will have a different id, but they will have the same date. Now I need to figure out a way how I can display each individual order based upon date. So the items that have the same date will be displayed together showing that they were ordered together as that users first order....then the next set of items with the same date will be order #2, and so on Do I need to put a while statement saying? while(date=date) { -display the items with the same date... -next set of same dates will be displayed below -and so on }
-
[SOLVED] PHP/MySQL Insert/Delete multiple question
SocomNegotiator replied to SocomNegotiator's topic in PHP Coding Help
Why is that...? -
[SOLVED] PHP/MySQL Insert/Delete multiple question
SocomNegotiator replied to SocomNegotiator's topic in PHP Coding Help
It looks really nice thanks man...however this is the error i get 0Could not move row 5 Error: 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 'order (id, user_id, item_id, amount) VALUES (5, 8, 1, 4)' at line 1 Could not move row 6 Error: 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 'order (id, user_id, item_id, amount) VALUES (6, 8, 4, 5)' at line 1 Could not move row 9 Error: 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 'order (id, user_id, item_id, amount) VALUES (9, 8, 7, 12)' at line 1 Could not remove pre_order items from order_db Error: 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 'order WHERE id IN ('0', '0', '0')' at line 1 -
[SOLVED] PHP/MySQL Insert/Delete multiple question
SocomNegotiator posted a topic in PHP Coding Help
Ok well I have a page that brings up items that a user has put in their "cart". There is no limit to how much they can add to it, but these items when added are kept in a pre_order table of the db. Now on this page I want a submit button that will submit all the items they have chosen and put them into the order table of the db and then deleting the stuff from the pre_order table. Here is how that pre_order table works. A user adds a single item...that item gets an id, user_id, item_id, and timestamp...So each item added has its own pre_order id. So I need a way that when the user clicks on the submit order button it will take every pre_order id that has to do with their user_id and transfer it to the order table of the db. Is there a way to do this...? Each item is it's own row... -
Ok well I am trying to grab information from two tables based on the info. in one table. So there are three tables involved. I have a user table, item table, and a pre_order table. The pre_order table has the item_id, user_id, and amount/quantity. Now I want to take those fields and use a left join so I can create a page that will show the user what they have in "their cart" essentially. Here is what I have... <?php $user_id = $user->inf['id']; $lname = $user->inf['last_name']; $db->query('SELECT docj_user.id, item.id, item.name, item.description, pre_order.amount FROM pre_order LEFT JOIN item ON pre_order.item_id = item.id LEFT JOIN docj_user ON pre_order.user_id = docj_user.id') or die(mysql_error()); $count = $db->num_rows(); if ($count == 0) { echo "<br /><div id='case'><p align='center' style='color: red;'>You have no orders to view.</p></div>"; } ?> <style type="text/css"> .menu22 ul{ margin: 0px; padding: 0px; float: left;} .menu22 ul li{ display: inline; margin:2px 5px 5px 20px;} </style> <div class="menu22" align="left"> <ul> <?php while($row = $db->fetch_array()) { ?> <form id='order_form' action='?page=view_item' method='post'><input type='hidden' name='user_id' value='<?=$row['docj_user.id']?>'/> <li> <ul style="width: 200px; height: 125px;"> <li>Item Name: <?=$row['item.name']?></li><br /> <li>Description: <?=$row['item.description']?></li><br /> <li>Quantity: <?=$row['pre_order.amount']?></li> </ul> </li> </form> <?php } ?> </ul> <br style="clear: left" /> </div> Now the code here brings up the correct amount of fields that user has because of the count variable I have. However, it is not bringing up the docj_user.id for the hidden field or any of the variables for the list. Any ideas would be much appreciated. Thanks
-
[SOLVED] Need help with PHP/MySQL count
SocomNegotiator replied to SocomNegotiator's topic in PHP Coding Help
-
[SOLVED] Need help with PHP/MySQL count
SocomNegotiator replied to SocomNegotiator's topic in PHP Coding Help
That worked like a charm thank you very much!!!! -
[SOLVED] Need help with PHP/MySQL count
SocomNegotiator replied to SocomNegotiator's topic in PHP Coding Help
So then you would call that by saying $row['SUM(credit_amount)'] or $row['credit_amount'] -
Well I am trying to count all of one field in a table. There could be 50 or more rows with different credit amounts...well I want the sum of all of them together. I know this is probably pretty basic, but I can't figure it out. Here's what I have: $credit_total=mysql_query("SELECT COUNT(credit_amount) FROM credits"); $row = mysql_fetch_assoc($credit_total); $row['COUNT(credit_amount)'] = $count; Now $count for some reason is just showing up as nothing Any ideas?
-
That did work...thanks a lot man!!!
-
Hey when I take out id it works. Is there a way I can keep id in? I need to declare it so I can't leave it out.
-
Hmmm....it still returns every game. You got another idea?
-
Well I have some games that I am querying...here is the code SELECT id,game FROM ladders ORDER BY game LIMIT 1 Now when I say limit 1 it actually limits it to one result. Well I want to limit it to one result for each game. Because I have more than one game, and some games are listed more than once. So I don't need the same game to come up twice. Any ideas what I can put...?
-
[SOLVED] Simple php query problem
SocomNegotiator replied to SocomNegotiator's topic in PHP Coding Help
Here was the problem...I need to just use this query instead of the other one SELECT id,name FROM ladders WHERE game = '".$ladderg['game']."' ORDER BY name -
[SOLVED] Simple php query problem
SocomNegotiator replied to SocomNegotiator's topic in PHP Coding Help
Yeah sorry when I copied and pasted I accidentally took it out some how, but I had that in and it still does not work. -
Ok this does not make sense...here is the code that does not work. $ladder_game=mysql_query("SELECT * FROM ladders WHERE id=".$ladder_url); $ladderg=mysql_fetch_assoc($ladder_game); $ladders=mysql_query("SELECT id,name FROM ladders game=".$ladderg['game']." ORDER BY name"); while(list($id,$name)=mysql_fetch_row($ladders)){ $ladderlist.="<option value='$id'>$ladders[game]$name</option>\n"; } I get this error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result Now get this I know that $ladderg['game'] works because when I insert it into the echo I get the game. However, check out the code below it works and the only thing I do is take out game=".$ladderg['game']." from the query and it works fine. $ladder_game=mysql_query("SELECT * FROM ladders WHERE id=".$ladder_url); $ladderg=mysql_fetch_assoc($ladder_game); $ladders=mysql_query("SELECT id,name FROM ladders ORDER BY name"); while(list($id,$name)=mysql_fetch_row($ladders)){ $ladderlist.="<option value='$id'>$ladderg[game]$ladders[game]$name</option>\n"; } Now you see that I took out that part in the query, but I stuck it down in the <option> and it works fine. Does anyone have any idea why the top code does not work?
-
Hmmm...so no quotes around variable in the echo statement. I knew it was going to be something stupid
-
Does anyone know why this does not work... <select name="name" id="name"> <option selected="selected"> </option> <? $sql2 = "SELECT * FROM teams ORDER BY name ASC"; $result2 = mysql_query($sql2); while($data2 = mysql_fetch_array($result2)) { $country = $data2['name']; echo "<option value='$country'>$country</option>"; } ?> </select>
-
If you notice how my page is set^ I first create the a-z list and then add a parameter at the end that equals the letter that you are choosing. From there I am trying to match match the letter chosen with the first letter of the username....So simply when I click on A it will grab all of the usernames that start with A, and so on with the rest of the alphabet. The way you have the code looks like you have a page for each letter which I want to use the same page, but change the result based on the letter picked.
-
Well I am wanting to query the DB for the users usernames....based on their first letter they will be put on the a-z list accordingly. So when I click on B from the a-z list it will show all of the users full username that start with the letter "B", and then also some other info. on that user like their first name, last name, etc.
-
Well I am trying to make an a-z list that will show all of my users usernames in the a-z list by the first letter of their username. I have tried a lot of different things, and I can't seem to get it to work. Any help would be much appreciated. Here is the code I have now which isn't working: <?php $_root = './'; require_once($_root . '_core/common.php'); $skin->initiate(); ?> <table width='450' border='0' cellspacing='1' cellpadding='2' bgcolor='#000000'> <tr bgcolor="#666666"> <td width='450' valign='center' background="" align='center' colspan='5'><b><font face='verdana' size='-2' color='#ffffff'> <a href='http://somewhere.com/members.php?letter=a'>A</a> | <a href='http://somewhere.com/members.php?letter=b'>B</a> | <a href='http://somewhere.com/members.php?letter=c'>C</a> | <a href='http://somewhere.com/members.php?letter=d'>D</a> | <a href='http://somewhere.com/members.php?letter=e'>E</a> | <a href='http://somewhere.com/members.php?letter=f'>F</a> | <a href='http://somewhere.com/members.php?letter=g'>G</a> | <a href='http://somewhere.com/members.php?letter=h'>H</a> | <a href='http://somewhere.com/members.php?letter=i'>I</a> | <a href='http://somewhere.com/members.php?letter=j'>J</a> | <a href='http://somewhere.com/members.php?letter=k'>K</a> | <a href='http://somewhere.com/members.php?letter=l'>L</a> | <a href='http://somewhere.com/members.php?letter=m'>M</a> | <a href='http://somewhere.com/members.php?letter=n'>N</a> | <a href='http://somewhere.com/members.php?letter=o'>O</a> | <a href='http://somewhere.com/members.php?letter=p'>P</a> | <a href='http://somewhere.com/members.php?letter=q'>Q</a> | <a href='http://somewhere.com/members.php?letter=r'>R</a> | <a href='http://somewhere.com/members.php?letter=s'>S</a> | <a href='http://somewhere.com/members.php?letter=t'>T</a> | <a href='http://somewhere.com/members.php?letter=u'>U</a> | <a href='http://somewhere.com/members.php?letter=v'>V</a> | <a href='http://somewhere.com/members.php?letter=w'>W</a> | <a href='http://somewhere.com/members.php?letter=x'>X</a> | <a href='http://somewhere.com/members.php?letter=y'>Y</a> | <a href='http://somewhere.com/members.php?letter=z'>Z</a> </b></td> </tr> </table> <br><br /> <table width='450' border='0' cellspacing='1' cellpadding='2' bgcolor='#000000' align='left'> <tr bgcolor="#CCCCCC"> <td width='450' valign='center' background="" align='left' colspan='5'><b><font face='verdana' size='-2' color='#ffffff'> Members</b></td> </tr> <tr bgcolor="#666666"> <td width='55%' valign='center' bgcolor='' align='left'><b><font face='verdana' size='-2' color='#ffffff'>Username</b></td> <td width='30%' valign='center' bgcolor='' align='left'><b><font face='verdana' size='-2' color='#ffffff'>Date Joined</b></td> </tr> <?php $members=mysql_query("SELECT username, first_name, last_name, date_joined FROM ls_users WHERE username BETWEEN 'A' AND 'Z' ORDER BY username ASC"); while(list($username, $first_name, $last_name, $date_joined) = mysql_fetch_row($members)) { if ($members['username'] == $_GET['letter']) { ?> <tr bgcolor="#666666"> <td width='5%' valign='center' align='left'><font face='verdana' size='-1'><?php echo $username; ?></font></td> <td width='30%' valign='center' align='left'><font face='verdana' size='-1'><?php echo $date_joined; ?></font></td> </tr> <?php } } ?> </table> <br> <? $skin->compile(); ?>
-
Well I am trying to take the current date - 1 day to check my Database for users who joined at least 1 day ago form the current date....here is my code.... $cur_return = date("Y-m-d H:i:s"); $date = explode('-', $cur_return); $user_date = date("Y-m-d H:i:s", mktime(0,0,0, $date[1], $date[2]-1, $date[0])); // So $user_date is the current date - 1 day.....now I need to search the DB for any users who's join date is greater than this. For instance, the date is May 26th well with this would make it 2007-05-25 00:00:00. $RecentUser = 'SELECT username FROM ls_users WHERE date_joined > '.$user_date; $ResultUser = mysql_query($RecentUser); $getrow = mysql_fetch_array($ResultUser); echo '<li><a href="#"><img src="{skin}files/r1.jpg" alt="Username"><span>'.$getrow['username'].'</span></a></li>'; now for some odd reason this does not work....I know that the current date - 1 day works, because I did an echo on $user_date and it was " 2007-05-25 00:00:00" which is in the correct format as the date_joined field in the database. Any help would be much appreciated thanks....
-
Hey flash my partner and I are interested in fixing the problem for you. Please email me or contact me through [email protected] Thanks for your time.