Goodday Ladies and Gentle men.
Please i need a code that can take me to the description of a particular listed item on a website.
What i mean is, once i clicked on maybe the picture of a particular product from listed products on a site, it tends to take me to the full description of that particular product, showing the price and description of that singular product.
I already have the codes that lists all the product on a page.
Please i need response urgently.
Thanks and God bless!
Need a help pls!
Moderator: General Moderators
-
mikeashfield
- Forum Contributor
- Posts: 159
- Joined: Sat Oct 22, 2011 10:50 am
Re: Need a help pls!
There could be any number of ways to do this! Post the code you've got for displaying the items so we can get an understanding of where you're at so far.
Re: Need a help pls!
Thanks for your reply sir,
I have used this code to display the list of records. I will need a code that will display a single information when clicked.
Thanks...
THE CODES
<?php
//initiallize error array
$errors = array();
if (empty($_POST['date'])){
$errors[] = 'Enter the Specific Date in the order stated.';
} else {
$date = ($_POST['date']);
}
if (empty($errors)) { // If everything’s OK.
require_once ('connection.php'); // Connect to the db.
$q = "SELECT id, fullname, time_in, time_out, item_out, photo FROM visitors WHERE date_in = '$date' ORDER BY time_in DESC";
$r = @mysqli_query ($connection, $q);
$num = mysqli_num_rows ($r);
echo "There are currently <b>$num</b> searched member(s)";
if ($r) {
echo '<table align="center" cellspacing="3" cellpadding="3"
width="95%" bgcolor="#99CCFF"><tr><td align="left"> <b>S/n</b></td><td align="left"><b>Fullname</b></td><td align="left"><b>Time in</b></td><td><b>Time out</b></td><td><b>Item Out</b></td><td><b>Photograph</b></td><tr>
';
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$imgurl = 'uploads/'.$row["photo"].'';
echo '<tr><td>' . $row['id'] . '</td><td>' . $row['fullname'] . '</td><td>'. $row['time_in'] . '</td><td>' . $row['time_out'] . '</td><td>' . $row['item_out'] . '</td><td><a href= /project\uploads/'.$row["photo"].'>';
echo '<img src= "'.$imgurl.'" width=100 height=100>';
'</a></td></tr>' ;
}
echo '</table>';
mysqli_free_result ($r);
}else {
echo '<p> <b>No visitor was Retrieved. <em>This was due to a System error.</em> </b><br/></p>';
echo '<p>' . mysqli_error($connection) . '<br/><br/>Query:' . $q . '</p>';
}
} else {
echo '<h1>Error!</h1>
<p>The following error(s) occurred:<br />';
foreach ($errors as $msg) {
echo " - $msg<br/>\n";
}
echo '</p><p>Please try again.</p><p><br/></p>';
}
?>
I have used this code to display the list of records. I will need a code that will display a single information when clicked.
Thanks...
THE CODES
<?php
//initiallize error array
$errors = array();
if (empty($_POST['date'])){
$errors[] = 'Enter the Specific Date in the order stated.';
} else {
$date = ($_POST['date']);
}
if (empty($errors)) { // If everything’s OK.
require_once ('connection.php'); // Connect to the db.
$q = "SELECT id, fullname, time_in, time_out, item_out, photo FROM visitors WHERE date_in = '$date' ORDER BY time_in DESC";
$r = @mysqli_query ($connection, $q);
$num = mysqli_num_rows ($r);
echo "There are currently <b>$num</b> searched member(s)";
if ($r) {
echo '<table align="center" cellspacing="3" cellpadding="3"
width="95%" bgcolor="#99CCFF"><tr><td align="left"> <b>S/n</b></td><td align="left"><b>Fullname</b></td><td align="left"><b>Time in</b></td><td><b>Time out</b></td><td><b>Item Out</b></td><td><b>Photograph</b></td><tr>
';
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$imgurl = 'uploads/'.$row["photo"].'';
echo '<tr><td>' . $row['id'] . '</td><td>' . $row['fullname'] . '</td><td>'. $row['time_in'] . '</td><td>' . $row['time_out'] . '</td><td>' . $row['item_out'] . '</td><td><a href= /project\uploads/'.$row["photo"].'>';
echo '<img src= "'.$imgurl.'" width=100 height=100>';
'</a></td></tr>' ;
}
echo '</table>';
mysqli_free_result ($r);
}else {
echo '<p> <b>No visitor was Retrieved. <em>This was due to a System error.</em> </b><br/></p>';
echo '<p>' . mysqli_error($connection) . '<br/><br/>Query:' . $q . '</p>';
}
} else {
echo '<h1>Error!</h1>
<p>The following error(s) occurred:<br />';
foreach ($errors as $msg) {
echo " - $msg<br/>\n";
}
echo '</p><p>Please try again.</p><p><br/></p>';
}
?>
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Need a help pls!
You would have to transfer the id of the record (by id i refer to something unique to each record). Query strings is probably your best bet; your code would look like this
This is a basic script to accomplish what you have in mind; Hth.
Code: Select all
<?php
//
if ($_GET['id'] != '') {
if (is_numeric($_GET['id'])) {
// now you have the id so you can select the record from the database
$sql = "SELECT fieldname FROM table WHERE id = '" . mysql_real_escape_string($_GET['id']) . "' ";
$qry = mysql_query($sql) or die(mysql_error());
while ($array = mysql_fetch_array($qry)) {
echo $array['fieldname'];
}
}
}
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering