Jump to content

Recommended Posts

I have this assignment from college. I have to admit i am pretty week in php programming. HTML was way too easy. It had been three days trying to solve this one but I coudn't figure it out in the combo box for now, and freankly I have no idea how to display the last table shown in this thread.

 

I need to store these data in an array and then display it in a combo box:

 

 

 

121024970.jpg

 

 

 

The combo box will appear like this (notice: The third book "photoshop" must be displayed as the default book(selected)):

 

 

156348025.jpg

 

 

 

And finally I need to display the following table using the list and eachfunctions with while loop:

 

 

238473489.jpg

 

 

 

PLEASE HELP ME... THANK YOU

Share this post


Link to post
Share on other sites

This my solution for now.. but I didn't know how to dispaly it in a combo box or in the table

 

<html>
<body>
<table border=2 cellspacing=2 cellpadding=2 align="center">
<tr>
<td>Choose a book</td>
<td>
<select name="books">
<?php
$books=array(		HD=> array( 'bkid'=>'100',
							   'bktitle'=>'Computer Hardware',
							   'bkprice'=>'12.250',
							   'discount'=>'0.10'),
						   OS=> array( 'bkid'=>'200',
							   'bktitle'=>'Operating System',
							   'bkprice'=>'25.5',
							   'discount'=>'0.15'),

						  PS=> array( 'bkid'=>'300',
							   'bktitle'=>'Photoshop',
							   'bkprice'=>'8.3',
							   'discount'=>'0.20'));
//From here It's probalby wrong
foreach($books as $key => $value){
$value[bkid]." - ".$value[bktitle]." -OR ".$value[bkprice]." - ".$value[discount]."<br>";
echo "<option></option>";	 // I don;t know what to do here
}
?>
</select>
</td>
</tr>
</body>
</html>

Share this post


Link to post
Share on other sites

I don't know much of image hosts>>>

 

 

This is the link to the array:

 

http://i.imgur.com/IAb3b.jpg

 

 

The combo box will appeare like this taking in consideration that 'photoshop' is the default selected

 

http://i.imgur.com/iF0QM.jpg

 

and the table:

http://i.imgur.com/qRcxH.jpg

 

 

 

Other Links:

 

 

 

121024970.jpg

 

 

 

 

 

 

156348025.jpg

 

 

 

 

 

 

238473489.jpg

  • Like 1

Share this post


Link to post
Share on other sites

It may be helpful, I will tell again.

 

<html>

<body>

<table border=2 cellspacing=2 cellpadding=2 align="center">

<tr>

<td>Choose a book</td>

<td>

<select name="books">

<?php

$books=array( HD=> array( 'bkid'=>'100',

'bktitle'=>'Computer Hardware',

'bkprice'=>'12.250',

'discount'=>'0.10'),

OS=> array( 'bkid'=>'200',

'bktitle'=>'Operating System',

'bkprice'=>'25.5',

'discount'=>'0.15'),

 

PS=> array( 'bkid'=>'300',

'bktitle'=>'Photoshop',

'bkprice'=>'8.3',

'discount'=>'0.20'));

//From here It's probalby wrong

foreach($books as $key => $value){

// $value[bkid]." - ".$value[bktitle]." -OR ".$value[bkprice]." - ".$value[discount]."<br>";

echo "<option>".$value[bkid]." - ".$value[bktitle]." -OR ".$value[bkprice]." - ".$value[discount]."</option><br>"; // I don;t know what to do here

}

?>

</select>

</td>

</tr>

</body>

</html>

Share this post


Link to post
Share on other sites

bro u can create that table by gui mode by using phpmyadmin on wamp/mamp/lamp server based on what os u r using and then copy the code and use in php.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×