Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem displaying data

Status
Not open for further replies.

sue0912

MIS
Jun 19, 2007
50
US
Hi,

I have a Zen Cart store that I have added some code that will display in the product description info page. My problem is that I can not tell if it is my PHP code or the Query.

I am new to PHP/MHSQL. I am more of a Coldfusion/SQL developer. Below is my code and a link to help explain.

I believe that the results are trying to display but just don't appear and I don't know where to look for errors. The folks over at the zen cart forum have been much help but I need some more.

Code:
<?php //it is recommended to always use the full <?php opening, not the shorthand <?


// Get all records in all columns from table and put it in $result.
$query="select Manual, Figure, Item, rev, link, Name from zen_product_manuals where itemnumber = '6630206' Order By Manual, Figure";
$result=mysql_query($query) or die(mysql_error());


?>
<table border="0">
<tbody>
<tr>
<th nowrap="nowrap">Manual</th>
<th nowrap="nowrap">Figure</th>
<th nowrap="nowrap">Item</th>
<th nowrap="nowrap">Rev</th>
<th nowrap="nowrap">Name</th>
</tr>
<?php
while($row=mysql_fetch_array($result)){ //while may not be best kind of loop - foreach is made for stepping through arrays
?>
<tr>
<td nowrap="nowrap"><?php echo $row['manual']; ?></td> <!-- these #getmanual.link# will need to be replaced with PHP statements -->
<td nowrap="nowrap"><?php echo $row['figure']; ?>"<a href="<?php echo $row['link']; ?>"><?php echo $row['figure']; ?></a></td>
<td nowrap="nowrap"><?php echo $row['item']; ?>"</td>
<td nowrap="nowrap"><?php echo $row['name']; ?></td>
</tr>
<?php
} //end of while loop ?>
</tbody>
</table>

Link:

Any help is so appreciated!
Thanks
Sue
 
You query asks for Manual, Figure, Item and Name, notice all start with a capital letters.

Yet you want to display manual, figure, item, and name without capital letters. The only correctly addressed field is link, in lower case letters. Which is getting displayed if you look at the source code.

However since there is nothing in your links to display you can;t actually see them.

So fix the capitalization, and and put something inside your links.

<a href="..."> [red]this is empty[/red]</a>


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
That was it! Thank you so much Phil!!! I can not believe it didn't notice that.

May I ask one more question? Can you explain the syntax how PHP/MYSQL calls a URL variable?

For example in Coldfusion I can pass along a variable for the following query
<cfquery name="getmanual" datasource="eesparts" dbtype="ODBC">
SELECT Distinct Manual, Figure, item, rev, link, Name
FROM powerscreen_machines
WHERE productID = '#URL.Product_ID#'
ORDER BY Manual, Figure
</cfquery>

In my query for MYSQL, I would like to replace the '6630206' with the products_id or the model number that is called on the product_info_display.php.
so it would be something like
$query="select Manual, Figure, Item, rev, link, Name from zen_product_manuals where itemnumber = "zen_products.products_model" Order By Manual, Figure"

Sue

 
I got it thanks!!!!

it was and correct me if I can wrong...

itemnumber = $products_model

Sue
 
That will depend on how you are sending the variable over,
if it comes from a form with a POST method you'll need to look for it in the $_POST variable and if its coming in the URL or a form with a GET method it will be in the $_GET variable.

Basically:

Code:
[red]$Product_ID_variable=mysql_real_escape_string($_POST['varname']);[/red]
$query="SELECT Distinct Manual, Figure, item, rev, link, Name
FROM powerscreen_machines
WHERE productID = '[red]" .[/red] $Product_ID_variable [red]. "[/red]'
ORDER BY Manual, Figure";





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Well, I am not sure. I looked on tbl_product_info_display.php page to see how the code called products_model.

It reference $products_model.

I test it on 2 other products and it pulled the correct data from the table and displayed it correct. So I am not sure!!

maybe I should have $_Get

confused now :)
Sue
 
It should not be to hard to figure out, does your URL have something like:


Or do you have a Form that's submitting to this page?


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
yes $_GET then.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top