
anthony-needs-you
Members-
Posts
52 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
anthony-needs-you's Achievements

Member (2/5)
0
Reputation
-
code not pulling results out
anthony-needs-you replied to anthony-needs-you's topic in PHP Coding Help
tried them, but still nothing The code displays the right number of columns and rows, just no data. . . -
can anyone see why this: <?php include ($_SERVER['DOCUMENT_ROOT'].'/admin/library/config.php'); include ($_SERVER['DOCUMENT_ROOT'].'/admin/library/opendb.php'); ?> <table cellspacing="3" cellpadding="3"> <?php $query = "SELECT id, vImage, vName, vDesc, vPrice FROM vehicles WHERE vCategory = 'lease' ORDER BY id"; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if(mysql_num_rows($result)==0) { echo(' <span class="noVehicles"><strong>No Vehicles Listed</strong></span> '); } while(list($id, $vName, $vDesc, $vPrice, $vImage) = mysql_fetch_array($result)) { if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo '<td><div class="stocklisting-row"> <div class="stockphoto"><img src="vehicles/<?php echo $vImage;?>" width="125" /></div> <div class="stocktext"> <div class="stockname"><?php echo $vName;?></div> <div class="stockdesc"><?php echo $vDesc;?></div> <div class="stockprice">£<?php echo $vPrice;?> a month</div> <div class="stockmore"><a href="specification.php?id=<?php echo $id;?>">view details</a></div> </div> </div></td>'; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } } ?> </tr> </table> <?php include ($_SERVER['DOCUMENT_ROOT'].'/admin/library/closedb.php'); ?> doesnt pull the results in this area: echo '<td><div class="stocklisting-row"> <div class="stockphoto"><img src="vehicles/<?php echo $vImage;?>" width="125" /></div> <div class="stocktext"> <div class="stockname"><?php echo $vName;?></div> <div class="stockdesc"><?php echo $vDesc;?></div> <div class="stockprice">£<?php echo $vPrice;?> a month</div> <div class="stockmore"><a href="specification.php?id=<?php echo $id;?>">view details</a></div> </div> </div></td>'; it displays the correct rows just with empty values? I think this part maybe wrong: while(list($id, $vName, $vDesc, $vPrice, $vImage) = mysql_fetch_array($result))
-
cool cheers
-
Hi i'm currently using this to set 1 column of results: <?php //check if the starting row variable was passed in the URL or not if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) { //we give the value of the starting row to 0 because nothing was found in URL $startrow = 0; //otherwise we take the value from the URL } else { $startrow = (int)$_GET['startrow']; } $query = "SELECT id, vName, vDesc, vPrice, vImage FROM vehicles ORDER BY id DESC LIMIT $startrow, 5"; $result = mysql_query($query) or die('Error : ' . mysql_error()); if(mysql_num_rows($result)==0) { echo(' <span class="noVehicles"><strong>No Vehicles Listed</strong></span> '); } while(list($id, $vName, $vDesc, $vPrice, $vImage) = mysql_fetch_array($result, MYSQL_NUM)) { ?> <div class="stocklisting"> <div class="stockphoto"><img src="pics/<?php echo $vImage;?>" width="125" /></div> <div class="stocktext"> <div class="stockname"><?php echo $vName;?></div> <div class="stockdesc"><?php echo $vDesc;?></div> <div class="stockprice">£<?php echo $vPrice;?> a month</div> <div class="stockmore"><a href="specification.php?id=<?php echo $id;?>">view details</a></div> </div> </div> <?php } ?> I now need to change this to a 2 column layout. I have found this script: <?php $dataTest = array('a','b','c','d','e','f','g'); $table = '<table>'; $counter = 0; // find total number of items in array. If it's not an even number // we need to add 1 so as to avoid breaking the table by // omitting the final cell $total = count($dataTest); if ($total%2 != 0) { $total+=1; } // loop through the array for ($i=0;$i<count($dataTest);$i++) { if ($counter%2 == 0) { // first column $table .= '<tr><td>' . $dataTest[$i] . '</td>'; } else { // second column $table .= '<td>' . $dataTest[$i] . '</td></tr>'; } $counter++; } // complete table and output results $table .= '</table>'; echo $table; ?> Does anyone know how to tie the two together? many thanks for any help
-
does anyone know how i would attach an attachment to this email script?
-
How do i create an email attachment using this script <?php error_reporting(E_NOTICE); function valid_email($str) { return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; } if($_POST['name']!='' && $_POST['telephone']!='' && $_POST['e_mail']!='' && $_POST['county']!='' && valid_email($_POST['e_mail'])==TRUE && strlen($_POST['message'])>5) { $to = '[email protected]'; $headers = 'From: '.$_POST['e_mail'].''. "\r\n" . 'Reply-To: '.$_POST['e_mail'].'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $subject = "Website Enquiry - contact page"; $name = "Name: " . $_POST["name"] . "\r\n"; $telephone = "Telephone: " . $_POST["telephone"] . "\r\n"; $county = "County: " . $_POST["county"] . "\r\n"; $repair = "Repair: " . $_POST["repair"] . "\r\n"; $enquiry = "Message: " . $_POST["message"] . "\r\n"; $body = "$name\n $telephone\n $repair\n $county\n $enquiry\n"; //$message = htmlspecialchars($_POST['message'] && $_POST['first_name'] && $_POST['last_name']); if(mail($to, $subject, $body, $headers)) {//we show the good guy only in one case and the bad one for the rest. echo '<div class="success-msg">Thank you '.$_POST['name'].'. Your message was sent</div>'; } else { echo '<div class="error-msg">Message not sent. Please make sure you\'re not running this on localhost and also that you are allowed to run mail() function from your webserver</div>'; } } else { echo '<div class="error-msg">Please make sure you filled all the required fields, that you entered a valid email and also that your message contains more then 5 characters.</div>'; } ?> this is the html upload <input name="photo" id="photo" size="30" type="file" class="fileUpload" /> Any help is appreciated
-
the problem i'm getting with that is if you type in a destination and leave the other fields to any it will pull all of the holidays from the table and not just the destination do you know why?
-
if i leave the destination field blank the any's will pull all of the holidays
-
hi everyone, i have a search with ranges its working fine except for the 'any ...' fields here is the html <span class="search-subhed">Holiday Type?</span><br /> <select name="breakType" class="field"> <option selected="selected">-- please select --</option> <option value="holidaybreaks">Holiday Breaks</option> <option value="cruises">Cruises</option> <option value="citybreaks">City Breaks</option> <option value="sporting">Sporting Holidays</option> <option value="flights">Flights</option> <option value="hotel">Hotel Bookings</option> </select><br /> <span class="search-subhed">Destination?</span><br /> <input name="where" type="text" value="" class="field" /><br /> <span class="search-subhed">Price?</span><br /> <select name="pricerange" class="field"> <option value="0:10000" selected="selected">Any price</option> <option value="0:500">£0-£500</option> <option value="501:1000">£501-£1000</option> <option value="1001:2000">£1001-£2000</option> <option value="2000:10000">Over £2000</option> </select><br /> <span class="search-subhed">Duration?</span><br /> <select name="stay" class="field"> <option value="1:42" selected="selected">Any duration</option> <option value="1:1">1 night</option> <option value="2:2">2 nights</option> <option value="3:3">3 nights</option> <option value="4:4">4 nights</option> <option value="5:5">5 nights</option> <option value="6:6">6 nights</option> <option value="7:7">7 nights</option> <option value="8:8">8 nights</option> <option value="9:9">9 nights</option> <option value="10:10">10 nights</option> <option value="12:12">12 nights</option> <option value="14:14">14 nights</option> <option value="21:21">21 nights</option> <option value="21:42">Over 21 nights</option> </select><br /> <input name="search" type="submit" id="search" value="Search" /> and here is part of the php if($breakType == 'holidaybreaks') { list($min,$max) = explode(':',$_POST['pricerange'],2); list($minstay,$maxstay) = explode(':',$_POST['stay'],2); $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE duration BETWEEN '$minstay' AND '$maxstay' AND price BETWEEN '$min' AND '$max' AND destination LIKE '%$where%'"); When 'any price' or 'any duration' is selected with a destination it shows no results?
-
Hi i have some sort by buttons: <form method="POST" action="<?php echo($_SERVER['PHP_SELF']); ?>"> <input name="resort" value="resort" type="image" onMouseOver="this.src='elements/images/layout/r-resort-active.gif'" onMouseOut="this.src='elements/images/layout/r-resort-inactive.gif'" src="elements/images/layout/r-resort-inactive.gif" class="button" border"0"> </form> This is the code it posts to: if(isset($_POST['authorDate'])){ $authorDate=$_POST['authorDate']; $type="authorDate"; }elseif(isset($_POST['hotel'])){ $hotel=$_POST['hotel']; $type="hotel"; }elseif(isset($_POST['destination'])){ $destination=$_POST['destination']; $type="destination"; }elseif(isset($_POST['resort'])){ $resort=$_POST['resort']; $type="resort"; }elseif(!isset($_POST[''])){ $type="hotel"; } and this is the part of the code it sorts via $type: $query = "SELECT id, destination, author, resort, hotel, authorDate, description, stars FROM reviews ORDER BY $type LIMIT $startrow, 10"; It works in firefox but not in IE does anyone know why?
-
you star, thanks
-
Hi everyone, i am trying to create a search fuction with a price range. The html for the price range is: <select name="pricerange" class="field"> <option selected="selected">any price</option> <option value="0:100">£0 - £100</option> <option value="101:300">£101 - £300</option> <option value="301:500">£301 - £500</option> </select> and the php is list($min,$max) = explode(':',$_POST['pricerange'],2); $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE destination LIKE '%$where%' AND duration LIKE '%$stay%' AND price BETWEEN '%$min' AND '%$max'"); The price range is not working?
-
[SOLVED] searching for multiple keywords
anthony-needs-you replied to anthony-needs-you's topic in PHP Coding Help
Thanks works perfectly -
Hi i have two bits of code. On their own they work fine. How would i put them together? $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE destination LIKE '%$where%'");[code] $result = mysql_query("SELECT departureDate, expireDate, airport, destination, resort, hotel, duration, board, price, description, customerRef, mystiqueRef, stars FROM holiday WHERE duration LIKE '%$stay%'");[/code]