hola, debido a que este tema también le puede servir a otra persona que este buscando
lo mismo que Tu y no tenia nada que hacer hice algo parecido a lo que tu quieres.
es en php y Ajax
yo te sugiero que en ves de $_GET uses $_POST y ajax
en Google puedes encontrar mucha info
y que uses filtros incluido
mysql_real_escape_string
yo estoy con;
php 5.3.3-7 Linux
para el primer file que seria el
index.php
Code:
Código HTML:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>php Ajax</title>
</head>
<script type="text/javascript">
function getMarca(int){
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("divShow").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","onChange.php"+int,true);
xmlhttp.send();
}
</script>
<body>
<?php
$arrayList = array('dell','sony','hp');
?>
<br /><br />
<div align="center">
Selecione una
<select onChange="getMarca('?op=opn&pc=' + this.value);">
<option>Marca
<?php
for($i=0;$i<count($arrayList);$i++){
echo '<option value="the'.$arrayList[$i].'">'.ucfirst($arrayList[$i])."\n";
}
?>
</select>
</div>
<br /><br />
<div id="divShow" align="center"></div>
</body>
</html>
y para el file:
onChange.php
code:
Código PHP:
<?php
function theAjax($theAjax){
return isset($_GET[$theAjax]) ? $_GET[$theAjax] : "";
}//opn
echo 'Extra occion!: ',theAjax('op');
$Lpc = theAjax('pc');
$arrayTBList = array(
'thedell' => 'dellpc',
'thesony' => 'sonypc',
'thehp' => 'hppc',
);
$TBpc = isset($arrayTBList[$Lpc]) ? $arrayTBList[$Lpc] : "dellpc";
//Cambiar Valores...
$con = mysql_connect("HostDB","UserDB","PaswdDB");
if (!$con){
die('Could not connect: ' . mysql_error());
}
//Cambiar DB...
mysql_select_db("Tu-Db-Name", $con);
$result = mysql_query("SELECT * FROM $TBpc");
echo "<br /><br /><table border='1'>
<tr>
<th>Precio</th>
<th>Modelo</th>
<th>Foto</th>
<th>Descripción</th>
<th>Producto ID</th>
<th>Fecha de Registro</th>
<th> Ultima actualización </th>
</tr>";
while($row = mysql_fetch_array($result)){
echo "<tr>",
"<td>$",$row['precio'],"</td>",
"<td>",$row['modelo'],"</td>",
"<td>" .'<img src="folde/images/',$row['imgRoot'],'" width="400" height="300" /> ',"</td>",
"<td>",$row['etcTxt'],"</td>",
"<td>",$row['UqId'],"</td>",
"<td>",$row['date'],"</td>",
"<td>",$row['udate'],"</td>",
"</tr>";
}
echo "</table><br /><br />";
function parse_youtube_url($url,$return='embed',$width='',$height='',$rel=0){
$urls = parse_url($url);
//url is http://youtu.be/xxxx
if($urls['host'] == 'youtu.be'){
$id = ltrim($urls['path'],'/');
}
//url is http://www.youtube.com/embed/xxxx
else if(strpos($urls['path'],'embed') == 1){
$id = end(explode('/',$urls['path']));
}
//url is xxxx only
else if(strpos($url,'/')===false){
$id = $url;
}else{
parse_str($urls['query']);
$id = $v;
if(!empty($feature)){
$id = end(explode('v=',$urls['query']));
}
}
//return embed iframe
if($return == 'embed'){
return '<iframe width="'.($width?$width:560).'" height="'.($height?$height:349).'" src="http://www.youtube.com/embed/'.$id.'?rel='.$rel.'" frameborder="0" allowfullscreen></iframe>';
}
//return normal thumb
else if($return == 'thumb'){
return 'http://i1.ytimg.com/vi/'.$id.'/default.jpg';
}//return hqthumb
else if($return == 'hqthumb'){
return 'http://i1.ytimg.com/vi/'.$id.'/hqdefault.jpg';
}else{// else return id
return $id;
}
}
$TBpc .= theAjax('eigts');
switch($TBpc){
case 'dellpc':
echo parse_youtube_url('http://www.youtube.com/watch?v=xhtgw-tOj-o','embed');
break;
case 'sonypc':
echo parse_youtube_url('http://www.youtube.com/watch?v=hXAVjmsjSB0','embed');
break;
case 'hppc':
$video = parse_youtube_url('http://www.youtube.com/watch?v=Scs7DZhQ72E','embed');
$img = parse_youtube_url('http://www.youtube.com/watch?v=Scs7DZhQ72E','hqthumb');
echo "Imagen<br /> <img src=\"",$img,"\" width=\"200\" height=\"150\"><br /> y Video<br />";
echo $video;
break;
case 'dellpc-eigts.net':
print_r($_GET);
break;
}
?><br /><br /><a href="#" onClick="getMarca('?eigts=-eigts.net&ext=opA&et=epB');">extra op</a>
recuerda que tu lo tienes que modificar ese código solo es para que entiendas como
jugar con php y ajax
en esta URL podras ver un ejemplo:
www.eigts.net/phpAjax.php
solo lo dejo temporal el URL vista previa de ese code después editare es tema
si quieres una copia de la estructura de my DB copia este code basico y lo ejecutas en un
file php te creara la base de dato o solo las tablas:
code:
Código PHP:
<form action="" method="post">
Nombre de Base de Datos <input name="thedb" type="text">si no existe sera creada con ese nombre<br />
<input name="crear" type="submit" value="Submit">
</form>
<?php
if(isset($_POST['crear'])){
$db = isset($_POST['thedb']) ? $_POST['thedb'] : "";
if(empty($db)){
echo 'DB Name empty!';
}else{
//Cambiar Valores...
$con = mysql_connect("HostDB","UserDB","PaswdDB");
if (!$con){
die('Could not connect: ' . mysql_error());
}
// Create database
if (mysql_query("CREATE DATABASE IF NOT EXISTS $db",$con)){
echo "La Base de Datos fue creada";
if(mysql_select_db("$db", $con)){
$sqlA = "CREATE TABLE IF NOT EXISTS `dellpc` (
`hwId` int(11) NOT NULL AUTO_INCREMENT,
`thepc` varchar(100) COLLATE utf8_spanish_ci NOT NULL DEFAULT '0',
`precio` varchar(100) COLLATE utf8_spanish_ci NOT NULL DEFAULT '300',
`modelo` varchar(50) COLLATE utf8_spanish_ci NOT NULL DEFAULT '2182012',
`imgRoot` varchar(200) COLLATE utf8_spanish_ci NOT NULL DEFAULT '0',
`etcTxt` text COLLATE utf8_spanish_ci NOT NULL DEFAULT '',
`UqId` varchar(100) COLLATE utf8_spanish_ci NOT NULL DEFAULT '',
`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`udate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`hwId`),
UNIQUE KEY `UqId` (`UqId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;";
mysql_query($sqlA, $con);
$sqlB = "CREATE TABLE IF NOT EXISTS `sonypc` (
`hwId` int(11) NOT NULL AUTO_INCREMENT,
`thepc` varchar(100) COLLATE utf8_spanish_ci NOT NULL DEFAULT '0',
`precio` varchar(100) COLLATE utf8_spanish_ci NOT NULL DEFAULT '250',
`modelo` varchar(50) COLLATE utf8_spanish_ci NOT NULL DEFAULT '2182012',
`imgRoot` varchar(200) COLLATE utf8_spanish_ci NOT NULL DEFAULT '0',
`etcTxt` text COLLATE utf8_spanish_ci NOT NULL DEFAULT '',
`UqId` varchar(100) COLLATE utf8_spanish_ci NOT NULL DEFAULT '',
`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`udate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`hwId`),
UNIQUE KEY `UqId` (`UqId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;";
mysql_query($sqlB, $con);
$sqlC = "CREATE TABLE IF NOT EXISTS `hppc` (
`hwId` int(11) NOT NULL AUTO_INCREMENT,
`thepc` varchar(100) COLLATE utf8_spanish_ci NOT NULL DEFAULT '0',
`precio` varchar(100) COLLATE utf8_spanish_ci NOT NULL DEFAULT '200',
`modelo` varchar(50) COLLATE utf8_spanish_ci NOT NULL DEFAULT '2182012',
`imgRoot` varchar(200) COLLATE utf8_spanish_ci NOT NULL DEFAULT '0',
`etcTxt` text COLLATE utf8_spanish_ci NOT NULL DEFAULT '',
`UqId` varchar(100) COLLATE utf8_spanish_ci NOT NULL DEFAULT '',
`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`udate` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`hwId`),
UNIQUE KEY `UqId` (`UqId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;";
mysql_query($sqlC, $con);
echo " y las Tablas fueron creadas";
mysql_close($con);
}else{
die ('Error: ' . mysql_error());
}
}
}
}
?>
espero y te sirva y si es lo que buscas modificalo a tu gusto...
today for my php code was free
-