Jump to content

Populate table help


svalding

Recommended Posts

hey all, I am having a bit of a problem with this table.

 

What I've got goin on is an inventory app that pulls a list of users from a database for users to select, and when they hit "get info" the selected user is stored in a variable, and that variable is used in another query to pull out the relevant information for that specific user. The query I have works, as mysql is not spitting any errors out to me. Here is the code. I have commented the sections that I am having problems with.

 

<?php
   
include inventory.php;

                
        $username = $_POST['username'];
  # Main connection information      
$db_host='localhost';
        $db_database='#########';
        $db_username='#######';
        $db_password='#########';
$db_config = 'mysql'; 


        $connection = mysql_connect($db_host,$db_username,$db_password); 
if (!$connection)
{
	die ("Could not connect to database using supplied credentials");
}

$db_select = mysql_select_db($db_database); 
if (!$db_select)
{
	die ("Could not select database");
}

        $getphoneinfo = "SELECT * FROM inventory WHERE name = '".$selectedname."'";
        if (!$getphoneinfo)
        {
                die ("Could not query database");
        }

        $phone_query = mysql_query($getphoneinfo);
        if (!$phone_query)
        {
                die ("No data received from database");
        }
        
        $phone_result = mysql_result($phone_query);
        
        $phone_fetch = mysql_fetch_row($phone_result);

        $number_phone = mysql_numrows($phone_query);
       

        


echo '

<html> 
<head>
<title>Dover Chemical Cellphone Inventory System</title>
</head>
<body>
<!-- create a table for the header banner -->
<table bgcolor="00619e" height="150" width="100%">
<tr>	
	<td align="center"><font color="white" size="+24">Dover Chemical Cellphone Inventory</font></td>
</tr>
<!-- close banner table -->
</table>


<hr width=50%></hr>
<center>
<table>
        <tr>
                <td><p> Account Number: <b>######### </b>| Password: <b>##########</b> | Call : <b>##############</b></p></td>
        </tr>
</table>
</center>
<hr width=50%></hr>
<!-- I stole this code from the dover website for whitespace, editing the table for height. Thanks Mr. Harr!!!! -->
<table height="16%">
<tr>
	<td>
					<font color=#ffffff>
						--------- --------- --------- ---------
						--------- --------- --------- ---------
					</font>

	</td>
        </tr>
</table>

<!-- center it all up in one fell swoop! -->
<div align="center">
<!-- now we need a table to place the form in -->
<table>


<!-- form used to select the appropriate user -->
<label>Selected User:  ';    echo $username; echo '</label>
<!-- done with the form piece -->
<!-- now we close the container -->

</table>';


         


echo '
<!-- now we need a table to put the various information about the users phone -->
<br />
<br />
<table align="center" width="30%" height="20%">
<tr>
	<td>Cellphone model</td><td>'; 
               $phone_fetch = mysql_fetch_array($phone_result); echo $row['model'];   echo '</td>
                        
</tr>
<tr>
	<td>Cellphone number</td><td>'; echo "blank" ; echo '</td>
</tr>
<tr>
	<td>IMEI number</td><td>'; echo "blank"; echo '</td>
</tr>
<tr>
	<td>SIM number</td><td>'; echo "blank"; echo '</td>
</tr>
<!-- close information table -->
</table>

</div>
<!-- poor mans whitespace, not as cool as brians -->
<br />
<br />
<br />
<!-- Copyright mumbo-jumbo...gotta cover your ass now adays -->
<center><font size="-14" face="papyrus">Copyright © 2008 Dover Chemical Corporation</font></center>

</body>
</html>
';

mysql_close();
?>

Link to comment
https://forums.phpfreaks.com/topic/98828-populate-table-help/
Share on other sites

<?php
   
include inventory.php;

                
        $username = $_POST['username'];
  # Main connection information      
$db_host='localhost';
        $db_database='#########';
        $db_username='#######';
        $db_password='#########';
$db_config = 'mysql'; 

/* I am building the query here, using the $selectedname variable that the user gets stored to in inventory.php */
        $connection = mysql_connect($db_host,$db_username,$db_password); 
if (!$connection)
{
	die ("Could not connect to database using supplied credentials");
}

$db_select = mysql_select_db($db_database); 
if (!$db_select)
{
	die ("Could not select database");
}

        $getphoneinfo = "SELECT * FROM inventory WHERE name = '".$selectedname."'";
        if (!$getphoneinfo)
        {
                die ("Could not query database");
        }

        $phone_query = mysql_query($getphoneinfo);
        if (!$phone_query)
        {
                die ("No data received from database");
        }
        
        $phone_result = mysql_result($phone_query);
        
        $phone_fetch = mysql_fetch_row($phone_result);

        $number_phone = mysql_numrows($phone_query);
       

        


echo '

<html> 
<head>
<title>Dover Chemical Cellphone Inventory System</title>
</head>
<body>
<!-- create a table for the header banner -->
<table bgcolor="00619e" height="150" width="100%">
<tr>	
	<td align="center"><font color="white" size="+24">Dover Chemical Cellphone Inventory</font></td>
</tr>
<!-- close banner table -->
</table>


<hr width=50%></hr>
<center>
<table>
        <tr>
                <td><p> Account Number: <b>######### </b>| Password: <b>##########</b> | Call : <b>##############</b></p></td>
        </tr>
</table>
</center>
<hr width=50%></hr>
<!-- I stole this code from the dover website for whitespace, editing the table for height. Thanks Mr. Harr!!!! -->
<table height="16%">
<tr>
	<td>
					<font color=#ffffff>
						--------- --------- --------- ---------
						--------- --------- --------- ---------
					</font>

	</td>
        </tr>
</table>

<!-- center it all up in one fell swoop! -->
<div align="center">
<!-- now we need a table to place the form in -->
<table>

/* this part works, I just post in the selected user from the inventory.php page */	
<!-- form used to select the appropriate user -->
<label>Selected User:  ';    echo $username; echo '</label>
<!-- done with the form piece -->
<!-- now we close the container -->

</table>';


         


echo '
<!-- now we need a table to put the various information about the users phone -->
<br />
<br />
<table align="center" width="30%" height="20%">
<tr>
	<td>Cellphone model</td><td>'; 

/* This is where the queried data needs to go, but I can't seem to get it to go there. */
               $phone_fetch = mysql_fetch_array($phone_result); echo $row['model'];   echo '</td>
                        
</tr>
<tr>
	<td>Cellphone number</td><td>'; echo "blank" ; echo '</td>
</tr>
<tr>
	<td>IMEI number</td><td>'; echo "blank"; echo '</td>
</tr>
<tr>
	<td>SIM number</td><td>'; echo "blank"; echo '</td>
</tr>
<!-- close information table -->
</table>

</div>
<!-- poor mans whitespace, not as cool as brians -->
<br />
<br />
<br />
<!-- Copyright mumbo-jumbo...gotta cover your ass now adays -->
<center><font size="-14" face="papyrus">Copyright © 2008 Dover Chemical Corporation</font></center>

</body>
</html>
';

mysql_close();
?>

 

I think the query is returning results, as there are no errors that get fired saying the query failed. I just started with this php nonsense, so hopefully I am coding everything together right. Any insite will definitely help me out a lot.

 

-- P.S. I reattached the code with the comments put in.

Link to comment
https://forums.phpfreaks.com/topic/98828-populate-table-help/#findComment-505719
Share on other sites

Try this:

 

<?php
   
include inventory.php;

                
        $username = $_POST['username'];
  # Main connection information      
$db_host='localhost';
        $db_database='#########';
        $db_username='#######';
        $db_password='#########';
$db_config = 'mysql'; 

/* I am building the query here, using the $selectedname variable that the user gets stored to in inventory.php */
        $connection = mysql_connect($db_host,$db_username,$db_password); 
if (!$connection)
{
	die ("Could not connect to database using supplied credentials");
}

$db_select = mysql_select_db($db_database); 
if (!$db_select)
{
	die ("Could not select database");
}

        $getphoneinfo = "SELECT * FROM inventory WHERE name = '".$selectedname."'";
        if (!$getphoneinfo)
        {
                die ("Could not query database");
        }

        $phone_query = mysql_query($getphoneinfo);
        if (!$phone_query)
        {
                die (mysql_error() . "<p>With Query:<br>$getponeinfo");
        }
        
        $phone_fetch = mysql_fetch_assoc($phone_query);
        $number_phone = mysql_num_rows($phone_query);
       

        


echo '

<html> 
<head>
<title>Dover Chemical Cellphone Inventory System</title>
</head>
<body>
<!-- create a table for the header banner -->
<table bgcolor="00619e" height="150" width="100%">
<tr>	
	<td align="center"><font color="white" size="+24">Dover Chemical Cellphone Inventory</font></td>
</tr>
<!-- close banner table -->
</table>


<hr width=50%></hr>
<center>
<table>
        <tr>
                <td><p> Account Number: <b>######### </b>| Password: <b>##########</b> | Call : <b>##############</b></p></td>
        </tr>
</table>
</center>
<hr width=50%></hr>
<!-- I stole this code from the dover website for whitespace, editing the table for height. Thanks Mr. Harr!!!! -->
<table height="16%">
<tr>
	<td>
					<font color=#ffffff>
						--------- --------- --------- ---------
						--------- --------- --------- ---------
					</font>

	</td>
        </tr>
</table>

<!-- center it all up in one fell swoop! -->
<div align="center">
<!-- now we need a table to place the form in -->
<table>

/* this part works, I just post in the selected user from the inventory.php page */	
<!-- form used to select the appropriate user -->
<label>Selected User:  ';    echo $username; echo '</label>
<!-- done with the form piece -->
<!-- now we close the container -->

</table>';


         


echo '
<!-- now we need a table to put the various information about the users phone -->
<br />
<br />
<table align="center" width="30%" height="20%">
<tr>
	<td>Cellphone model</td><td>'; 

echo $phone_fetch['model'];   echo '</td>
                        
</tr>
<tr>
	<td>Cellphone number</td><td>'; echo "blank" ; echo '</td>
</tr>
<tr>
	<td>IMEI number</td><td>'; echo "blank"; echo '</td>
</tr>
<tr>
	<td>SIM number</td><td>'; echo "blank"; echo '</td>
</tr>
<!-- close information table -->
</table>

</div>
<!-- poor mans whitespace, not as cool as brians -->
<br />
<br />
<br />
<!-- Copyright mumbo-jumbo...gotta cover your ass now adays -->
<center><font size="-14" face="papyrus">Copyright © 2008 Dover Chemical Corporation</font></center>

</body>
</html>
';

mysql_close();
?>

Link to comment
https://forums.phpfreaks.com/topic/98828-populate-table-help/#findComment-505994
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.