ali_b Posted April 1, 2007 Share Posted April 1, 2007 Hello, I have managed to insert data into a database and display it in a table. i just did a very basic example to see if it would work. so what i get is this: ID Name Age 1 Ali 17 2 blah 20 to insert the data i used this : <html> <head> <title>Forms</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form name="form1" method="post" action="insert.php"> <p>Name:-<br> <input name="name" type="text" id="name"> <br> <br> Age:-<br> <input name="age" type="text" id="age"> <br> <br> <input type="submit" name="Submit"> </p> </form> </body> </html> to display it in a table i used this: <?php $mysqlLink = mysql_connect( 'localhost' , 'name' , 'pw' ); mysql_select_db( 'menugenc_clients' , $mysqlLink ); $table = 'test'; if( $result = mysql_query('SELECT * FROM ' . $table ) ) { echo '<table border="1">'; $fieldCount = mysql_num_fields( $result ); echo "<tr>"; for( $i = 0; $i < $fieldCount; $i++ ) { echo '<td><strong>' . mysql_field_name( $result, $i ) . '</strong></td>'; } echo "</tr>"; if( mysql_num_rows( $result ) ) { while( $row = mysql_fetch_row( $result ) ) { echo '<tr>'; for( $i = 0; $i < $fieldCount; $i++ ) { echo '<td>' . $row[$i] . '</td>'; } echo '</tr>'; } } else { echo '<tr><td colspan="' . $fieldCount . '">No rows selected...</td></tr>'; } echo '</table>'; } else { echo 'Query Error: ' . mysql_error( ); } mysql_close( $mysqlLink ); ?> What i want to real one to look like is this: ID Name delivery 1 name of restraunt [picture of a wee van] but the "name of the restraunt" bit will be a link to another page with info about the restraunt. and if it can deliver there will be a picture of a van and if it can there will be a picture of a van with a cross through it. The most important bit is the link bit. could you please tell me how to do this? Cheers very much ali. Link to comment https://forums.phpfreaks.com/topic/45180-displaying-data/ Share on other sites More sharing options...
DeathStar Posted April 1, 2007 Share Posted April 1, 2007 wel.. try calling the name as a link with this as you use id's! ex: <a href='userview.php?id=$id'>$name</a> //the name will be called trough userid <br> <img src='$pic'> // the picture link Link to comment https://forums.phpfreaks.com/topic/45180-displaying-data/#findComment-219320 Share on other sites More sharing options...
ali_b Posted April 1, 2007 Author Share Posted April 1, 2007 wel.. try calling the name as a link with this as you use id's! ex: Code: <a href='userview.php?id=$id'>$name</a> //the name will be called trough userid <br> <img src='$pic'> // the picture link im not very familur to the php?id=$id stuff. how does this work? i dont understand how i can link it to the page about the restraunt.... normally if the restraunt info page was called rest1 the link would be <a href="rest1.html"></a> so what would i call the page about the restraunt :S:S:S loooool i dont think i could have explained that any worse but hopefully u get me Cheers Link to comment https://forums.phpfreaks.com/topic/45180-displaying-data/#findComment-219330 Share on other sites More sharing options...
MadTechie Posted April 1, 2007 Share Posted April 1, 2007 if you enter a page with "?something=other" ie index.php?something=other the php page can pull that infomation for example echo $_GET['something']; // will return "other" Link to comment https://forums.phpfreaks.com/topic/45180-displaying-data/#findComment-219335 Share on other sites More sharing options...
ali_b Posted April 1, 2007 Author Share Posted April 1, 2007 i sorta get it, ill give it a go now Link to comment https://forums.phpfreaks.com/topic/45180-displaying-data/#findComment-219378 Share on other sites More sharing options...
DeathStar Posted April 1, 2007 Share Posted April 1, 2007 as they say: God loves a try. Link to comment https://forums.phpfreaks.com/topic/45180-displaying-data/#findComment-219383 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.