r/DatabaseHelp • • Mar 23 '15

Can you build a relational database using WAMP?

I have been given a project to design a food calculator, and the way i was think about setting the tables out is to build one that has all the meals and another that has all the ingredients and get it to reference that table when the user clicks the meal, so it will display all the ingredients and what they cost. Is this possible? or do I need to rethink?

Any help/tutorials would be appreciated.

2 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/insert-team-name May 15 '15

this is my code so far, but its throwing an error of Notice: Object of class mysqli_result could not be converted to int in C:\wamp\www\TheSunInn\add.php on line 121.

	$sqlin = "SELECT * FROM ingredients";
	$result = mysqli_query($conn, $sqlin);

	if ($result != 0) {
		echo '<label>Ingredients:';
		echo '<select name="InName">';
		echo '<option value="">all</option>';

		$num_results = mysqli_num_rows($result);
		for ($i=0;$i<$num_results;$i++) {
			$row = mysqli_fetch_array($result);
			$name = $row['InName'];
			echo '<option value="' .$InName. '">' .$InPrice. '</option>';
		}

		echo '</select>';
		echo '</label>';

1

u/BinaryRockStar May 15 '15

It's probably this line:

 if ($result != 0) {

Why are you comparing it to zero? What resource are you using to learn or copy from? From what I'm reading it should be:

 if ($result != FALSE) {

The next issue is that you're referring to $InName and $InPrice without defining them anywhere, and you're never referring to $name after initialising it.