Click here to Skip to main content
15,889,863 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So i have a table named: BabyNames
I have attributes: BoyNames, GirlNames, UserID and Favourites - i have added the last two in so I can add a favorite option

On my php script, there is script in which allows user to select a letter and it displays the baby names related

I also want them to have a favorite button so they can store some of their favorite names

Can someone help me out? with both SQL and PHP code. Do i need to assign an ID to the boy and girl names?

See below PHP at present.

What I have tried:

if (isset($_GET["initial"])) {
      $initial=$_GET["initial"];
      $dbQuery=$conn->prepare("select * from BabyNames Where BoyNames like :initial AND GirlNames like :initial");
      $initial=$initial.'%';
      $dbParams=array('initial'=>$initial);
      $dbQuery->execute($dbParams);
	   echo "<table border='1' width='400'>
		  <br><tr>
		  <th> Boy Names</th>
		  <th> Girl Names</th>
		  <th> Girl Names</th>
		  </tr></br>";
      while ($dbRow = $dbQuery->fetch(PDO::FETCH_ASSOC)) {
		echo "<tr>";
		echo "<td>";
		echo $dbRow["BoyNames"]."<td>".$dbRow["GirlNames"];
		}
   } 
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900