Jump to content

SamNewbie

New Members
  • Posts

    4
  • Joined

  • Last visited

SamNewbie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Ch0cu3r, Yes, user_city and gender are listed as numbers. For this project, I cannot change the data within the database and the two entities have to be kept as numerical format. Is there anyway to make gender (currently 1 is male and 2 is female), display as male and female respectively? Is there a way to do this with city names as well? Currently 1 = Aberdeen, 2 = London etc... Thanks for your help.
  2. Hey, I have got the results displayed from the database when it gets the ID in the URL but I am having a problem with one the results, in lists.php, there is a list of cities as an array city=array(0=>"London") But in the results, it is displaying the '1' instead of 'London', i need it to display 'London'. Below is my coding... it is all connected to the database. How do i change the data type? <?php if (isset($_GET['id'])){ $query="SELECT*FROM user WHERE user_id=".$_GET['id']; $results = mysql_query($query) or die (mysql_error()); while($row = mysql_fetch_array($results)){ echo "Name: ".$row['user_firstname']." ".$row['user_surname']; echo "<br /><br />"; echo "Date of Birth: ".$row['user_dob']; echo "<br /><br />"; echo "Gender: ".$row['user_gender']; echo "<br /><br />"; echo "City: ",$row['user_city']; echo "<br /><br />"; } } Thanks for any help!
  3. Hello, I need some help on my PHP coding. I need the ?=ID to show up on the URL when the user logs in and then to be able to use GET['id'] to show the results (first name, surname, dob etc). Below is my coding I have so far: Heading.php - this is where the user will log in. <div id="heading"> <h2>Sports Pal</h2> <h5>Playing the same sport as you!</h5> <h5><a href="@">Home</a>: <a href="@">About</a>: <a href="@">Contact</a>: <a href="@">Advertise</a></h5> <div class="signin"> <?php if ($_SESSION['loggedin'] == true){ echo "<p>You are logged in.</p>\n"; }else{ echo "<p>Sign In:</p>\n"; } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> Username: <input type="text" name="liusername"> Password: <input type="password" name="lipassword"> <input type="submit" name="lisubmit" value="Sign In"> </form> </div> </div> Source code on profile.php <?php include "./includes/nav.php"; ?> <div id="content"> <h3>User Profile</h3> <?php $query="SELECT user_id, user_firstname, user_surname, user_dob, user_gender FROM user"; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_array($result); if ($_GET['id'] == $_SESSION['id']); //if (isset($_GET['id'])){ //$_GET['id'] == $_SESSION['id']; echo "<label>First Name: </label>"; echo $row['user_firstname']."<br />"; echo "<label>Surname: </label>"; echo $row['user_surname']."<br />"; echo "<label>Date of Birth: </label>"; echo $row['user_dob']."<br />"; echo "<label>Gender: </label>"; echo $row['user_gender']."<br />"; echo "<label>City: </label>"; ?> <br /> </div> Many thanks for your help
×
×
  • 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.