Maq
Administrators-
Posts
9,363 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Maq
-
Need some help checking if two fields match up in php
Maq replied to craigtolputt's topic in PHP Coding Help
Assuming your field names from the form and the field names from your DB are "username" and "code_number". This will also display an error if the username and code number do not match up. $sql = 'SELECT * FROM '.$_POST['tablename'].' WHERE `Item` = "'.$_POST['Item'].'" AND `username` = "'.$_POST['username'].'" AND `code_number` = "'.$_POST['code_number'].'" LIMIT 1'; $result = $db->query($sql); $numrows = $result->num_rows; $details = "total=$numrows"; $counter = 0; if($numrows > 0) { while ($row = $result->fetch_assoc()) { $details .= '&Item'.$counter.'='.urlencode($row['Item']); $details .= '&FirstName'.$counter.'='.urlencode($row['FirstName']); $details .= '&LastName'.$counter.'='.urlencode($row['LastName']); $details .= '&Company'.$counter.'='.urlencode($row['Company']); $details .= '&Address1'.$counter.'='.urlencode($row['Address1']); $details .= '&Address2'.$counter.'='.urlencode($row['Address2']); $details .= '&City'.$counter.'='.urlencode($row['City']); $details .= '&Postcode'.$counter.'='.urlencode($row['Postcode']); $details .= '&PhoneNumber'.$counter.'='.urlencode($row['PhoneNumber']); $details .= '&Location'.$counter.'='.urlencode($row['Location']); $details .= '&Identifier'.$counter.'='.urlencode($row['Identifier']); $counter++; } } else { echo "Your user name does not match your code number..."; } $db->close(); echo $details; } ?> -
Why don't you test it out? They are both totally different. Or you could have both... If the user doesn't know the exact breed then they can go by letter. If they do, then they can type in the exact name.
-
$query1 = "SELECT * FROM mentee_personal_details where mentee_id = '$m_mentee'"; echo $query1; $result1 = $conn->query($query1);
-
Need Advice - Are Alert Boxes Acceptable For Login System?
Maq replied to limitphp's topic in PHP Coding Help
What happens if they have JS disabled? -
When you click on this link from your "all.php" do the correct variables get set in your URL? You can also echo $query1 to make sure it's asking for the right info. Other than that it looks good, unless I'm missing something...
-
What's your question? Is there something in particular that's not working? Do you get errors? You're in the wrong section, this doesn't seem to have anything to do with math... Use code tags.
-
[SOLVED] How do I do an if statement for current page?
Maq replied to TechMistress's topic in PHP Coding Help
Ok I see. You wanted to make the sub categories actual links. Glad you figured it out. The code is a little sloppy and lacks documentation (my fault) but if it works that's all that matters right now, but I would strongly urge that you document so you understand what's going on in case you have to refer to that code again. -
What format do you want to print the day, month, and year? Here's a list of formats. Current date: $right_now = mktime(0, 0, 0, date("m"), date("d"), date("y")); echo "Current date: ".date("m/d/y", $right_now); ?> I have no clue what you mean by, " if I press a link it goes to the same date, next month, and current year.", or how that even makes sense.
-
You need to grab the value from the URL. Right now you're using the value from the first query rather than he one he clicked on. Add this line here: $m_mentee = $_GET['mentee']; $query1 = "SELECT * FROM mentee_personal_details where mentee_id = '$m_mentee'"; $result1 = $conn->query($query1); Also, this piece of code is wrong... $row = mysqli_fetch_assoc($result);{ $m_mentee = $row['mentee']; } should be: $row = mysqli_fetch_assoc($result); $m_mentee = $row['mentee'];
-
Yeah, dropfaith already posted a link for you...
-
Can you just post your code? If you don't have any, do you want the current time? Input from the user? What? I meant datatype. Is it a timestamp stored in a DB, a string, integer, what?
-
[SOLVED] How do I do an if statement for current page?
Maq replied to TechMistress's topic in PHP Coding Help
Assuming the sub-categories are "cat_name" from the "categories" table with a parent_id of $catid (the one from the URL). if(isset($_GET['cat'])){ // checks to see if cat is set $catid = $_GET['cat']; $query = "SELECT * FROM categories WHERE cat_id = $catid"; $query2 = "SELECT cat_name FROM categories WHERE parent_id = '$catid'"; $doit = mysql_query($query) or die("Error:" . mysql_error()); $doit2 = mysql_query($query2) or die(mysql_error()); if(!mysql_num_rows($doit)){ echo "Category Not found"; } else { while($getcatname = mysql_fetch_array($doit)){ $catname = $getcatname['cat_name']; } echo "" . $catname . " Projects "; if(!mysql_num_rows($doit2)) { echo 'no data found'; } else { while($row = mysql_fetch_array($result)){ echo "" . $row['cat_name'] . " "; } } } } ?> -
What type is your date stored in? date() $next_month = mktime(0, 0, 0, date("m")+1, date("d"), date("y")); echo "Next month is ".date("m/d/y", $next_month); ?>
-
Need more detail like: Where does the mentee come from? What are you trying to do? Here's a skeleton: $mentee = "mentee001" ?> Mentee:
-
But don't you want to be better than just fine...
-
$user = $_GET['username'];
-
[SOLVED] confirmation OK or CANCEL has the same result in ALL cases ?
Maq replied to programguru's topic in Javascript Help
Good to hear you still may want to look at the confirm() link i posted it has some cool little features. Please click the SOLVED button. -
[SOLVED] confirmation OK or CANCEL has the same result in ALL cases ?
Maq replied to programguru's topic in Javascript Help
Look at this site Javascript Confirm(). They use href's is their examples, this should solve your problem. -
So is the user clicking a link from somewhere (not mentioned) to get to compose.php? Then you want to store the username in a hidden field in compose.php and pass it to profile.php? So your steps should look like this: Profile.php $usernamepost = $_POST['usernamepost']; ?> Then on my Compose.php it will look like this $usernamepost = $_GET['$username']; ?> And then i can do this PS - Never use short tags, always use <?php.
-
I'm confused, you want the current username in the text box or you want it hidden with the value of $user? In compose.php: [code] You need to give it the correct value which I'm almost positive is $user or you could give it the username from SESSION Change it to: In profile.php you need to use the POST method not the get method... $username = mysql_real_escape_string($_POST['username']); I guess he wanted a text field but I have no clue...
-
Page with the link: $username = "james"; ?> Profile profile.php: $username = $_GET['username']; ?>
-
K, thanks for the help.
-
* Not tested * - This SHOULD echo the first 4 words of the string. $string = "With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post." $short = ""; $pieces = explode(" ", $string); for($i = 0; $i $short .= $pieces[$i] . " "; echo $short;
-
1) Never use short tags to start PHP, always use <?php. 2) You need to read up on the GET method. 3) You need to grab the value from the URL before you use it in your query: $id = $_GET['id']; $query = "SELECT * FROM `officers` WHERE id='$id'"; $result = mysql_query($query) or die("No Record Found!"); 4) Use tags next time.