Menu
I have made a search page in PHP to get rows of search result which match the search criteria.
On this result page,I want to add a ‘add to shortlist’button below each row,so that it can get added to a shortlist of results.
Then after that I should be able to view the shortlisted result rows on a separate page.
Can anyone guide me how to go about this.Maybe sessions to be used ,but how??
Thanks
Ashokvas
[code=php]<?
session_start();
if(!isset($_SESSION['shortlist'])){
$_SESSION['shortlist'] = array();
};
if(isset($_GET['storeID'])){
$_SESSION['shortlist'][] = $_GET['storeID'];
echo("that was added to your shortlist.");
};
?>[/code]
[code=php]<?
session_start();
if(!isset($_SESSION['shortlist'])){
$_SESSION['shortlist'] = array();
};
if(count($_SESSION['shortlist']) == 0){
echo("you have no results shortlisted.");
}else{
$i = 0;
while($i <= count($_SESSION['shortlist'])){
$rs = mysql_query("SELECT * FROM tblname WHERE primaryID = ".$_SESSION['shortlist'][$i]);
if(mysql_num_rows($rs)){
echo("<a href="veiwResultURL?ID=");
echo(mysql_result($rs, 0, "primaryID"));
echo("">");
echo(mysql_result($rs, 0, "title OR link text"));
echo("</a><br />");
};
$i++;
};
};
?>
[/code]
[code=php]echo("<a href="$PHP_SELF?storeID=".mysql_result($rs, 0, "primaryID"));[/code]
[code=php]// let q be the querystring to find in the results we get a new link:
echo("<a href="$PHP_SELF?storeID=".mysql_result($rs, 0, "primaryID")."&q=".$_GET['q']);[/code]
$nextOffset=$offset+ROWS;
if(!mysql_data_seek($rsVis,$offset))
echo "Error seeking data";?>
<?php
for($rowCounter=0;
(($rowCounter<ROWS)&&
($row_rsVis = mysql_fetch_assoc($rsVis)));
$rowCounter++){ ?>
<tr>
<td align="center" valign="top">Stats</td>
<td align="left" valign="top">
<td align="center" valign="top">Curriculum</td>
<td align="center" valign="top">Book</td>
</tr>
<tr>
<td width="76" height="119" align="left" valign="top"><a href="ModelStatsVisit.php?id=<?php echo $row_rsVis['id']; ?>"><img src="images/<?php echo $row_rsVis['foto1']; ?>" width="73" height="100" border="0" /></a></td>
<td width="367" align="left" valign="top"><h5> <?php echo $row_rsVis['alias_name']; ?></h5>
<p>Height:<?php echo $row_rsVis['height']; ?> cm, Measures:<?php echo $row_rsVis['meas_bres']; ?>-<?php echo $row_rsVis['meas_waist']; ?>-<?php echo $row_rsVis['meas_hip']; ?>. Latest assignment: (CV1Date) <strong><?php echo $row_rsVis['cv1_date']; ?>, </strong>(CV1 Title) <strong><?php echo $row_rsVis['cv1_title']; ?></strong>, (CV1 Text)<font class="normal">:<?php echo $row_rsVis['cv1_contents']; ?> .</font>
<p>
<td width="86" align="center" valign="top"><a href="Stats_CV.php?id=<?php echo $row_rsVis['id']; ?>"><img src="images/<?php echo $row_rsVis['foto2']; ?>" width="72" height="100" border="0" /></a></td>
<td width="75" align="center" valign="top"><img src="images/<?php echo $row_rsVis['foto3']; ?>" width="72" height="100" /></td>
</tr>
<tr>
<td height="23" colspan="4"><img src="Graphics/SimpleLine.jpg" width="625" height="5" /></td>
</tr>
<tr><td height="23" colspan="4"><div align="center">
<table width="635" border="0" cellspacing="0" cellpadding="5">
<tr>
<?php }
echo($offset+1)."-".
($rowCounter+$offset)." of";
echo" $totalRows_rsVis records found matching".
" your criterian<br>";
if($offset>0)
echo "nt<a href="search_Visitor_Result.php"?offset=".rawurlencode($previousOffset).">Previous</a>";
else
echo "<br>Previous";
if(($row_rsVis !=false)&&($totalRows_rsVis >$nextOffset))
echo"nt<a href="search_Visitor_Result.php"?offset=".rawurlencode($nextOffset).">Next</a>";
else
echo " Next";
}
else
{
header("Location:search_Visitor_Result2.php");
exit;
}
echo"<br><br><a href="SearchVisit.htm">Back to Search</a><br>";
?>
<td><table width="625" height="43" border="0" cellpadding="0" cellspacing="0" background="Graphics/Bar.gif">
<tr align="center" valign="middle">
<td width="57">Model Search </td>
<td width="44">News</td>
<td width="59">New Models </td>
<td width="53">New Faces </td>
<td width="66">Feature Models</td>
<td width="55">Model's book</td>
<td width="68">Branding Guide </td>
<td width="66">Model's Guide </td>
<td width="104"><p>Registration<br />Forms & Photos </p>
</td>
<td width="53">Contact Us </td>
</tr>
</table></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td height="23" colspan="4"><div align="center">Modelbranding.com is a business division of CD Computer & Development Ltda. and is an Internet News and Information Provider. The webcontents do not necessarily express the policies or opinion of the company or Modelbranding.com. The content is the exclusive responsibility of its author or creator. All rights reserved. </div></td>
</tr>
<tr>
<td height="46" colspan="4"> </td>
</tr>
<tr valign="top">
<td height="406" colspan="4"><!-- TemplateBeginEditable name="KeyWords" --><!-- TemplateEndEditable --></td>
</tr>
</table></td>
</tr>
[code=php] to start)
once that's done you should indent it so everything is moved in by 1 or 2 spaces for each brace it's captured by (makes it easier to spot failure to open/close braces as well as making finding the end of some scripts easier)
if you can do that I'll get working on changing it.
[code=php] and [/code]
tags.[code=php]
<?php require_once('Connections/dbconn.php'); ?>
<?php
$vareyecolor_rsVis = "%";
if (isset($_POST['eye_color'])) {
$vareyecolor_rsVis = (get_magic_quotes_gpc()) ? $_POST['eye_color'] : addslashes($_POST['eye_color']);
}
$varbrlo_rsVis = "%";
if (isset($_POST['brlo'])) {
$varbrlo_rsVis = (get_magic_quotes_gpc()) ? $_POST['brlo'] : addslashes($_POST['brlo']);
}
$varbrhi_rsVis = "%";
if (isset($_POST['brhi'])) {
$varbrhi_rsVis = (get_magic_quotes_gpc()) ? $_POST['brhi'] : addslashes($_POST['brhi']);
}
$varwstlo_rsVis = "%";
if (isset($_POST['wstlo'])) {
$varwstlo_rsVis = (get_magic_quotes_gpc()) ? $_POST['wstlo'] : addslashes($_POST['wstlo']);
}
$varwsthi_rsVis = "%";
if (isset($_POST['wsthi'])) {
$varwsthi_rsVis = (get_magic_quotes_gpc()) ? $_POST['wsthi'] : addslashes($_POST['wsthi']);
}
$varhiplo_rsVis = "%";
if (isset($_POST['hiplo'])) {
$varhiplo_rsVis = (get_magic_quotes_gpc()) ? $_POST['hiplo'] : addslashes($_POST['hiplo']);
}
$varhiphi_rsVis = "%";
if (isset($_POST['hiphi'])) {
$varhiphi_rsVis = (get_magic_quotes_gpc()) ? $_POST['hiphi'] : addslashes($_POST['hiphi']);
}
$varhtlo_rsVis = "%";
if (isset($_POST['htlo'])) {
$varhtlo_rsVis = (get_magic_quotes_gpc()) ? $_POST['htlo'] : addslashes($_POST['htlo']);
}
$varhthi_rsVis = "%";
if (isset($_POST['hthi'])) {
$varhthi_rsVis = (get_magic_quotes_gpc()) ? $_POST['hthi'] : addslashes($_POST['hthi']);
}
$varhcolor_rsVis = "%";
if (isset($_POST['hair_color'])) {
$varhcolor_rsVis = (get_magic_quotes_gpc()) ? $_POST['hair_color'] : addslashes($_POST['hair_color']);
}
$varwarea_rsVis = "%";
if (isset($_POST['w_area'])) {
$varwarea_rsVis = (get_magic_quotes_gpc()) ? $_POST['w_area'] : addslashes($_POST['w_area']);
}
if(empty($offset))
$offset=0;
define(ROWS,25);
mysql_select_db($database_dbconn, $dbconn);
$query_rsVis = sprintf("SELECT users.id, users.color_eyes, users.foto1, users.foto2, users.foto3, users.alias_name, users.meas_bres, users.meas_waist, users.meas_hip, users.height, users.cv1_date, users.cv1_title, users.cv1_contents FROM users WHERE users.color_eyes='%s' AND users.meas_bres>'%s' AND users.meas_bres<'%s' AND users.meas_waist>'%s' AND users.meas_waist<'%s' AND users.meas_hip>'%s' AND users.meas_hip<'%s' AND users.height>'%s' AND users.height<'%s' AND users.hair_color='%s' AND users.w_area='%s'", $vareyecolor_rsVis,$varbrlo_rsVis,$varbrhi_rsVis,$
varwstlo_rsVis,$varwsthi_rsVis,$varhiplo_rsVis,$va
rhiphi_rsVis,$varhtlo_rsVis,$varhthi_rsVis,$varhco
lor_rsVis,$varwarea_rsVis);
$rsVis = mysql_query($query_rsVis, $dbconn) or die(mysql_error());
$totalRows_rsVis = mysql_num_rows($rsVis);
?><?php
if ($totalRows_rsVis != 0)
{
$prevOffset=$offset-ROWS;
$nextOffset=$offset+ROWS;
if(!mysql_data_seek($rsVis,$offset))
echo "Error seeking data";?>
[/code]
[code=php]
<?php
for($rowCounter=0;
(($rowCounter<ROWS)&&
($row_rsVis = mysql_fetch_assoc($rsVis)));
$rowCounter++){ ?>
[/code]
[code=php]
<td width="76" height="119" align="left" valign="top"><a href="ModelStatsVisit.php?id=<?php echo $row_rsVis['id']; ?>"><img src="images/<?php echo $row_rsVis['foto1']; ?>" width="73" height="100" border="0" /></a></td>
<td width="367" align="left" valign="top"><h5> <?php echo $row_rsVis['alias_name']; ?></h5>
<p>Height:<?php echo $row_rsVis['height']; ?> cm, Measures:<?php echo $row_rsVis['meas_bres']; ?>-<?php echo $row_rsVis['meas_waist']; ?>-<?php echo $row_rsVis['meas_hip']; ?>. Latest assignment: (CV1Date) <strong><?php echo $row_rsVis['cv1_date']; ?>, </strong>(CV1 Title) <strong><?php echo $row_rsVis['cv1_title']; ?></strong>, (CV1 Text)<font class="normal">:<?php echo $row_rsVis['cv1_contents']; ?> .</font>
<p>
<td width="86" align="center" valign="top"><a href="Stats_CV.php?id=<?php echo $row_rsVis['id']; ?>"><img src="images/<?php echo $row_rsVis['foto2']; ?>" width="72" height="100" border="0" /></a></td>
<td width="75" align="center" valign="top"><img src="images/<?php echo $row_rsVis['foto3']; ?>" width="72" height="100" /></td>
</tr>
<tr>
[/code]
[code=php]
<?php }
echo($offset+1)."-".
($rowCounter+$offset)." of";
echo" $totalRows_rsVis records found matching".
" your criterian<br>";
if($offset>0)
echo "nt<a href="search_Visitor_Result.php"?offset=".rawurlencode($previousOffset).">Previous</a>";
else
echo "<br>Previous";
if(($row_rsVis !=false)&&($totalRows_rsVis >$nextOffset))
echo"nt<a href="search_Visitor_Result.php"?offset=".rawurlencode($nextOffset).">Next</a>";
else
echo " Next";
}
else
{
header("Location:search_Visitor_Result2.php");
exit;
}
echo"<br><br><a href="SearchVisit.htm">Back to Search</a><br>";
?>
[/code]
[code=php]
<?php
mysql_free_result($rsVis);
?>
[/code]
0.1.9 — BETA 6.17