hello guys, new to php trying to learn by watching some videos from youtube.
I have learned how to insert and show the data from the database. But here is where I am having a bit problem.
here is a code
function page.
Posted 22 March 2013 - 09:04 PM
hello guys, new to php trying to learn by watching some videos from youtube.
I have learned how to insert and show the data from the database. But here is where I am having a bit problem.
here is a code
function page.
Posted 22 March 2013 - 10:51 PM
Posted 22 March 2013 - 11:16 PM
I have a basic sample page with tables that lists the values from the database. I am very lost here
Edited by jonnash, 22 March 2013 - 11:18 PM.
Posted 23 March 2013 - 02:57 AM
Please use code tags around your code. It's the button that looks like <> in the editor.
Posted 23 March 2013 - 03:10 AM
function getPrinters() {
$query = mysql_query("SELECT * FROM printers") or die (mysql_error());
if (mysql_num_rows($query) == 0) {
echo "<tr><td colspan=\"3\">No Printers Were Found</td></tr>";
} else {
while($post = mysql_fetch_assoc($query)) {
$bran=$post['Brand'];
$mod=$post['Model'];
$off=$post['office'];
$loc=$post['Location'];
$ip=$post['IPAddress'];
$mac=$post['MACAddress'];
$id=$post['id'];
echo "<tr><td>" . $bran . "</td><td>" . $mod . "</td><td>" . $off . "</td><td>" . $loc . "</td><td>" . $ip . "</td><td>" . $post['MACAddress'] . "</td><td><a href=\"delete.php?id=" . $id . "\">Delete</a><br /><a href=\"edit.php?id=" . $id . "\">Edit</a></td></tr>";
}
Here you function look like this now...
Now after that in the page i mean modelsample.php look like this
<?php
include('includes/PrintFunctions.php');
?>
<html>
<head>
<title><?php echo $mod; ?></title>
</head>
<body>
<table>
<tr>
<td>Brand</td><td><?php echo $bran; ?></td>
</tr>
<tr>
<td>Model:</td><td><?php echo $mod; ?></td>
</tr>
<tr>
<td>Office:</td><td><?php echo $Off; ?></td>
</tr>
<tr>
<td>Location:</td><td><?php echo $loc; ?></td>
</tr>
<tr>
<td>IP Address:</td><td><?php echo $ip; ?></td>
</tr>
<tr>
<td>MAC Address:</td><td><?php echo $mac; ?></td>
</tr>
</table>
</body>
</html>
Edited by altafhpatel, 23 March 2013 - 03:11 AM.
Posted 23 March 2013 - 11:27 AM
thank you!
but how do I turn the Model into a link that will get taken to the modsample.php page?
function getPrinters() {
$query = mysql_query("SELECT * FROM printers") or die (mysql_error());
if (mysql_num_rows($query) == 0) {
echo "<tr><td colspan=\"3\">No Printers Were Found</td></tr>";
} else {
while($post = mysql_fetch_assoc($query)) {
$bran=$post['Brand'];
$mod=$post['Model'];
$off=$post['office'];
$loc=$post['Location'];
$ip=$post['IPAddress'];
$mac=$post['MACAddress'];
$id=$post['id'];
echo "<tr><td>" . $bran . "</td><td>" . $mod . "</td><td>" . $off . "</td><td>" . $loc . "</td><td>" . $ip . "</td><td>" . $post['MACAddress'] . "</td><td><a href=\"delete.php?id=" . $id . "\">Delete</a><br /><a href=\"edit.php?id=" . $id . "\">Edit</a></td></tr>";
}
Posted 23 March 2013 - 11:49 AM
Okay I figured out how to make the link
echo "<tr><td>" . $bran . "</td><td>" . '<a href="modsample.php?id=" . $mod . "\">Model</a>' . "</td><td>" . $off . "</td><td>" . $loc . "</td><td>" . $ip . "</td><td>" . $mac. "</td><td>" . $Ink . "</td><td>" . $Stock . "</td><td><a href=\"delete.php?id=" . $id . "\">Delete</a><br /><a href=\"edit.php?id=" . $id . "\">Edit</a></td></tr>";
But I when I get taken to the modsample.php page I get error
"Notice: Undefined variable: bran in C:\wamp\www\web\printer 2\printer\admin\modsample.php on line 11"
<?php
include('includes/PrintFunctions.php');
?>
<html>
<head>
<title><?php echo $mod; ?></title>
</head>
<body>
<table>
<tr>
<td>Brand</td><td><?php echo $bran; ?></td>
</tr>
<tr>
<td>Model:</td><td><?php echo $mod; ?></td>
</tr>
<tr>
<td>Office:</td><td><?php echo $off; ?></td>
</tr>
<tr>
<td>Location:</td><td><?php echo $loc; ?></td>
</tr>
<tr>
<td>IP Address:</td><td><?php echo $ip; ?></td>
</tr>
<tr>
<td>MAC Address:</td><td><?php echo $mac; ?></td>
</tr>
<tr>
<td>Ink Type:</td><td><?php echo $Ink; ?></td>
</tr>
</table>
</body>
</html>s
0 members, 0 guests, 0 anonymous users