wmguk Posted March 14, 2008 Share Posted March 14, 2008 Hey guys, Couple of things: 1) I have a field called login, but on some pages if the login has a space in the name it fails and doesnt pick up anything after the space. is there a script i can add to the top of the page to ensure it doesnt lose anything? 2)I need to try and add together everything in one field, where login = 5... for example, if the database table show login | amount 1 7 2 3 1 9 4 5 then if i query login = 1, should display 16 (7+9) any thoughts on how i would do that? thanks Link to comment https://forums.phpfreaks.com/topic/96173-couple-of-issues-doesnt-display-if-username-has-a-space-number-issues/ Share on other sites More sharing options...
accident Posted March 14, 2008 Share Posted March 14, 2008 can't help you without example of the html and code as for second problem do select sum(amount) from table where login = 1 GROUP BY login Link to comment https://forums.phpfreaks.com/topic/96173-couple-of-issues-doesnt-display-if-username-has-a-space-number-issues/#findComment-492289 Share on other sites More sharing options...
soycharliente Posted March 14, 2008 Share Posted March 14, 2008 1. Don't allow them to have spaces in their username? 2. SELECT SUM(`amount`) AS `amt_sum` FROM `table` WHERE `login`='1' Link to comment https://forums.phpfreaks.com/topic/96173-couple-of-issues-doesnt-display-if-username-has-a-space-number-issues/#findComment-492294 Share on other sites More sharing options...
wmguk Posted March 14, 2008 Author Share Posted March 14, 2008 the only issue is they need spaces in the usernames This is the form the submit button they click to view the stats page <form name='stats' action='stats.php' method='POST'><input type='hidden' name='login' value='" . $row['login'] . "'><input type='submit' class='main' name='Submit' value='Stats' /></form> this is the query codes <? //further up the page above the head $login = $_POST['login']; //Main Script include "scripts/connection.php"; if (!$con) { die( 'Could not connect: ' . mysql_error() ); } mysql_select_db($db, $con); $result = mysql_query("SELECT *, DATEDIFF(CURDATE(),creationdate) AS diff FROM album WHERE login = '$login'"); $result2 = mysql_query("SELECT SUM(`total`) AS `amt_sum` FROM orders WHERE loginid = '$login'"); $result3 = mysql_query("SELECT * FROM orders WHERE loginid = '$login'"); while($row = mysql_fetch_array($result3)) { $total = $row['total']; } while($row = mysql_fetch_array($result2)) { $num_rows = mysql_num_rows($result2); $ave = $row['amt_sum'] ; } while($row = mysql_fetch_array($result)) { $groom_firstname = $row['groom_firstname']; $ceremony = $row['ceremony']; $counters = $row['counters']; $pricing = $row['pricing']; $image_no = $row['image_no']; $ordervalue = $row['ordervalue']; $orders = $row['orders']; $diff = $row['diff']; $dateactived = date('jS F Y', strtotime($row['creationdate'])); $accessdetail = date('jS F Y - h:ia', strtotime($row['accessdetail'])); Link to comment https://forums.phpfreaks.com/topic/96173-couple-of-issues-doesnt-display-if-username-has-a-space-number-issues/#findComment-492308 Share on other sites More sharing options...
wmguk Posted March 14, 2008 Author Share Posted March 14, 2008 RESOLVED THANK YOU Link to comment https://forums.phpfreaks.com/topic/96173-couple-of-issues-doesnt-display-if-username-has-a-space-number-issues/#findComment-492357 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.