...

View Full Version : Need help with item display



SKY-ProToSs
05-29-2011, 02:55 AM
So, I am trying to make two scripts where the items in a database are selected through the while control statement. The columns from the database are selected and put into an array using mysqli_fetch_array.

I am able to get rows and things of that nature. I however, don't know how I would take a specific row and define it in the a href link.

I basically want only one row's strings passed on to the next page.

I can't remember how to do this, but I wrote what I know in two scripts:




<?php include("header.php"); ?>

<?php

echo "<ul>";

echo "<li> {$row['ITEM']} </li>";
echo "<li> {$row['PRICE']} </li>";
echo "<li> {$row['ITEMIMAGE']} </li>";

echo "</ul>";

?>

<?php include("footer.php"); ?>






<?php include("header.php"); ?>

<?php

$abc = mysqli_connect('localhost','<REMOVED>','<REMOVED>');
mysqli_select_db($abc,'<REMOVED>');

$query = mysqli_query($abc, "SELECT * FROM ITEMS") or die ("Our database encountered a problem");

echo "<ul>";

while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {

}

echo "</ul>";

mysqli_close($abc);

?>

<?php include("footer.php"); ?>



I know that I am supposed to store all of the items in the array $row.

I am uncertain about what I mentioned above. If I try to do a $row['ITEMNAME'] or put a key(), I am still clueless about how it's done.

I hope someone can help me, as I am trying to code a website for my brothers business. Thanks in advance, SKY-PROTOSS

[/PHP]

Ahlahn
05-29-2011, 03:25 PM
I don't think it's a good idea to put your db user name and password on the page- it would be wise to get rid of it first. I'm not sure what you're asking- I'm assuming you just want to display all the items in a row on the page.

I think you got most of it- here's what it should look like.


echo "<ul>";
//Assuming there will be > 1 result, the while loop will iterate through the $row array, so you simply have to insert your first script within the loop.

while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {

echo "<li>" . {$row['ITEM']} . "</li>";
echo "<li>" . {$row['PRICE']} . "</li>";
echo "<li>" . {$row['ITEMIMAGE']} . "</li>";
//a line break to distinguish each row
echo "<br />";
}

echo "</ul>";

ShaneC
05-30-2011, 05:15 AM
I've removed the sensitive credentials. Unfortunately I can't guarantee that a crawler didn't snatch them up. As such, I highly recommend changing your database username and password.

SKY-ProToSs
06-03-2011, 12:38 PM
I've removed the sensitive credentials. Unfortunately I can't guarantee that a crawler didn't snatch them up. As such, I highly recommend changing your database username and password.

I hope they did not get indexed on google. If that's the case then I will change them.

So, the idea for this was to display a specific item with a custom url.

So in other words, I am wanting to run a match with the link you click, to display only one item.

So if I have:

<a href="...">{$row['ITEMNAME']}</a>

what would I put to go directly to that item, since it's just going to display every item?

There has to be a way to run the item check without being specific? Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum